Skip to content

Commit

Permalink
Fixes #474 - Watermark backgrounds no longer inherit their canvas bac…
Browse files Browse the repository at this point in the history
…kground color
  • Loading branch information
lilith committed Jul 1, 2020
1 parent 676b030 commit 3cb1d32
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions imageflow_core/src/flow/nodes/scale_render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ impl NodeDefOneInputOneCanvas for DrawImageDef {
return Err(cerror!(c, "Failed to execute Scale2D: "));
}
}
canvas.compositing_mode = crate::ffi::BitmapCompositingMode::BlendWithSelf;

Ok(())
} else {
Expand Down
41 changes: 41 additions & 0 deletions imageflow_core/tests/visuals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ fn test_watermark_image() {
assert!(matched);
}



#[test]
fn test_watermark_image_command_string() {
let matched = compare_multiple(Some(vec![
Expand Down Expand Up @@ -241,6 +243,45 @@ fn test_watermark_image_command_string() {
assert!(matched);
}


#[test]
fn test_watermark_image_command_string_with_bgcolor() {
let matched = compare_multiple(Some(vec![
IoTestEnum::Url("https://s3-us-west-2.amazonaws.com/imageflow-resources/test_inputs/waterhouse.jpg".to_owned()),
IoTestEnum::Url("https://s3-us-west-2.amazonaws.com/imageflow-resources/test_inputs/dice.png".to_owned())
]), 500,
"Watermark1", POPULATE_CHECKSUMS, DEBUG_GRAPH, vec![
Node::CommandString{
kind: CommandStringKind::ImageResizer4,
value: "width=800&height=800&mode=max&bgcolor=aaeeff".to_string(),
decode: Some(0),
encode: None,
watermarks: Some(vec![imageflow_types::Watermark{
io_id: 1,
fit_box: Some(imageflow_types::WatermarkConstraintBox::ImagePercentage {x1: 30f32, y1: 50f32, x2: 90f32, y2: 90f32}),
fit_mode: Some(imageflow_types::WatermarkConstraintMode::FitCrop),
gravity: Some(imageflow_types::ConstraintGravity::Percentage {x: 100f32, y: 100f32}),
min_canvas_width: None,
min_canvas_height: None,
opacity: Some(0.9f32),
hints: Some(imageflow_types::ResampleHints{
sharpen_percent: Some(15f32),
down_filter: None,
up_filter: None,
scaling_colorspace: None,
background_color: None,
resample_when: None,
sharpen_when: None
}),

}
])
}
]
);
assert!(matched);
}

#[test]
fn test_watermark_image_small() {
let matched = compare_multiple(Some(vec![
Expand Down

0 comments on commit 3cb1d32

Please sign in to comment.