Skip to content

Commit

Permalink
Fix ConstraintMode::FitPad to pad instead of cropping, Fixes imazen#589
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Sep 29, 2022
1 parent dd6b731 commit 91acf69
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
16 changes: 16 additions & 0 deletions imageflow_core/tests/visuals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,22 @@ fn test_crop_exif(){

}

#[test]
fn test_fit_pad_exif(){

for ix in 1..9 {
let url = format!("https://s3-us-west-2.amazonaws.com/imageflow-resources/test_inputs/orientation/Landscape_{ix}.jpg");
let title = format!("test ConstraintMode::FitPad on jpeg with exif rotate {ix}");
let matched = compare(Some(IoTestEnum::Url(url)), 500, &title, POPULATE_CHECKSUMS, DEBUG_GRAPH,
vec![
Node::Decode { io_id: 0, commands: None },
Node::Constrain(Constraint { mode: ConstraintMode::FitPad, w: Some(70), h: Some(70), hints: None, gravity: None, canvas_color: None })
]);
assert!(matched);
}

}


#[test]
fn test_off_surface_region(){
Expand Down
8 changes: 8 additions & 0 deletions imageflow_core/tests/visuals/checksums.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@
"jpeg_crop": "0071CBD976FC79E41_0FB5487907981932B",
"matte_transparent_png": "03D1AA84D6ED36458.png",
"mountain_gif_scaled400": "03FB3160ED6A86E15_05C9232CFE2672D1C",
"test ConstraintMode::FitPad on jpeg with exif rotate 1": "00196D6A86FF77C80_0BF80F0AE71CD9A63",
"test ConstraintMode::FitPad on jpeg with exif rotate 2": "0539F9C3B850149CB_0BF80F0AE71CD9A63",
"test ConstraintMode::FitPad on jpeg with exif rotate 3": "0B43B2563C986473D_0BF80F0AE71CD9A63",
"test ConstraintMode::FitPad on jpeg with exif rotate 4": "03AE71E563BAA50E1_0BF80F0AE71CD9A63",
"test ConstraintMode::FitPad on jpeg with exif rotate 5": "0E5CFC4A0932ACF87_0BF80F0AE71CD9A63",
"test ConstraintMode::FitPad on jpeg with exif rotate 6": "0463725A658D46C9F_0BF80F0AE71CD9A63",
"test ConstraintMode::FitPad on jpeg with exif rotate 7": "04D1EC9C034ADD12F_0BF80F0AE71CD9A63",
"test ConstraintMode::FitPad on jpeg with exif rotate 8": "0DB362A903C79AC30_0BF80F0AE71CD9A63",
"test cropping jpeg with exif rotate 1": "0C862D7FC5A78146F_0AF9F04019B0BAF16",
"test cropping jpeg with exif rotate 2": "0D870139306239192_0AF9F04019B0BAF16",
"test cropping jpeg with exif rotate 3": "02CF2323FBBBA9D5D_0AF9F04019B0BAF16",
Expand Down
2 changes: 1 addition & 1 deletion imageflow_riapi/src/ir4/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl Ir4Layout{
i.scale = Some(ScaleMode::DownscaleOnly);
},
ConstraintMode::FitPad => {
i.mode = Some(FitMode::Crop);
i.mode = Some(FitMode::Pad);
i.scale = Some(ScaleMode::Both);
},
ConstraintMode::AspectCrop => {
Expand Down

0 comments on commit 91acf69

Please sign in to comment.