Skip to content

Commit

Permalink
Fix bug in watermark layout
Browse files Browse the repository at this point in the history
  • Loading branch information
lilith committed Jun 10, 2020
1 parent 51d01d1 commit 0859c3b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
4 changes: 3 additions & 1 deletion imageflow_core/src/flow/nodes/watermark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ impl NodeDefOneInputExpand for WatermarkDef{
canvas_color: None
};

let constraint_results = imageflow_riapi::ir4::process_constraint(input.w, input.h, &constraint).unwrap(); //TODO: fix unwrap
let watermark_info = ctx.job.get_image_info(watermark.io_id).map_err(|e| e.at(here!()))?;

let constraint_results = imageflow_riapi::ir4::process_constraint(watermark_info.image_width, watermark_info.image_height, &constraint).unwrap(); //TODO: fix unwrap

let w = constraint_results.scale_to.width() as u32;
let h = constraint_results.scale_to.height() as u32;
Expand Down
36 changes: 36 additions & 0 deletions imageflow_core/tests/visuals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,42 @@ fn test_watermark_image_command_string() {
assert!(matched);
}

#[test]
fn test_watermark_image_small() {
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/1_webp_a.sm.png".to_owned())
]), 500,
"WatermarkSmall", POPULATE_CHECKSUMS, DEBUG_GRAPH, vec![
Node::Decode {io_id: 0, commands: None},
Node::Constrain(imageflow_types::Constraint{
w: Some(800),
h: Some(800),
hints: None,
gravity: None,
mode: ConstraintMode::Within,
canvas_color: None
}),
Node::Watermark(imageflow_types::Watermark{
io_id: 1,
gravity: Some(imageflow_types::ConstraintGravity::Percentage {x: 100f32, y: 100f32}),
fit_box: Some(imageflow_types::WatermarkConstraintBox::ImagePercentage {x1: 0f32, y1: 0f32, x2: 90f32, y2: 90f32}),
fit_mode: Some(imageflow_types::WatermarkConstraintMode::Within),
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);
}
// Does not reproduce across different compiler optimizations
// #[test]
// fn test_image_rs_jpeg_decode(){
Expand Down
3 changes: 2 additions & 1 deletion imageflow_core/tests/visuals/checksums.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"Test_Apply_Orientation_Portrait_7.jpg": "0002098ACFD00B380_0AE4839D1D9B04C57",
"Test_Apply_Orientation_Portrait_8.jpg": "026BD1030254479A0_0AE4839D1D9B04C57",
"Test_Jpeg_Simple.jpg": "018BC932FB29F2C53_0AF9F040B874D83F7",
"Watermark1": "06E7792859C160C4C_0DE3336C466C67DD9",
"Watermark1": "008A242F2FBED3C1D_0DE3336C466C67DD9",
"WatermarkSmall": "09BF9877BE2CB36AC_0DE3336C466C67DD9",
"WhiteBalanceNight": "0D84206BD2DD308DA_05C9231C6124D62A8",
"encode_frymire": "07FC2C05A26B49BF1.png",
"encode_gradients": "00D10466A8552DCF6.png",
Expand Down

2 comments on commit 0859c3b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New misspellings found, please review:

  • ative
  • jpegtinysize
  • msbuild
  • untimes
To accept these changes, run the following commands
remove_obsolete_words=$(mktemp)
echo '#!/usr/bin/perl -ni
my $re=join "|", qw('"
ansii
au
benchmarkee
binwrite
bytepp
bytesize
castps
cleanpath
cmarker
coderay
coord
coverity
decompressor
dirs
divisorx
downcase
DRB
drmike
elsif
EOI
eprofile
eventmachine
executables
extname
falsey
federico
flowhq
fsevent
gdk
gemspec
GETJOCTET
gmail
gtk
GUINT
hexdigest
HPROFILE
Ilib
inotify
insertf
iprofile
JOCTET
JPOOL
jruby
JWRN
keepalive
lcs
leth
LGPL
MESSAGEBOX
Minitest
mmc
mtime
Nailgun
nathanael
nathanaeljones
ncpu
nokogiri
optparse
outputsize
portile
ramdisk
rcov
redhat
REGEXPS
rspec
RTEST
Rubocop
rubyforge
rvm
SDK
shortname
Shoulda
simd
Sqr
TESTUNIT
tmpfs
toolkits
unpackhi
unpacklo
WIDTHx
winmgmts
zedzone
zucchi
"');
next if /^($re)(?:$| .*)/;
print;' > $remove_obsolete_words
chmod +x $remove_obsolete_words
for file in .github/actions/spell-check/whitelist/54b3b066a6b4654f7e7a02e49e56a1b3c1c76c25.txt .github/actions/spell-check/whitelist/5ae660e58f0dca219d9dd5801aeffa0e4ad6e8fa.txt .github/actions/spell-check/whitelist/618f622b0f99f2500bd3dc383f7a2cef48b72e76.txt .github/actions/spell-check/whitelist/c5b95641888e2ab165141518065246c44002e236.txt .github/actions/spell-check/whitelist/e4840f3eb751a28d6a885096045c6f437a5e7000.txt .github/actions/spell-check/whitelist/whitelist.txt; do $remove_obsolete_words $file; done
rm $remove_obsolete_words
(
echo "
ative
jpegtinysize
msbuild
untimes
"
) | sort -u -f | perl -ne 'next unless /./; print' > new_whitelist.txt && mv new_whitelist.txt '.github/actions/spell-check/whitelist/0859c3bf2abc4d7651115c782f331a3c80710361.txt'
✏️ Contributor please read this
  • You can probably just add items into .github/actions/spell-check/whitelist/whitelist.txt.
  • If you need to use a specific token in one place and it shouldn't generally be used, you can
    add an item in .github/actions/spell-check/patterns.txt.

⚠️ Reviewers

At present, the action that triggered this message will not show its ❌ in this PR unless the branch is within this repository.
Thus, you should make sure that this comment has been addressed before merging this PR.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New misspellings found, please review:

  • ative
  • jpegtinysize
  • msbuild
  • untimes
To accept these changes, run the following commands
remove_obsolete_words=$(mktemp)
echo '#!/usr/bin/perl -ni
my $re=join "|", qw('"
ansii
au
benchmarkee
binwrite
bytepp
bytesize
castps
cleanpath
cmarker
coderay
coord
coverity
decompressor
dirs
divisorx
downcase
DRB
drmike
elsif
EOI
eprofile
eventmachine
executables
extname
falsey
federico
flowhq
fsevent
gdk
gemspec
GETJOCTET
gmail
gtk
GUINT
hexdigest
HPROFILE
Ilib
inotify
insertf
iprofile
JOCTET
JPOOL
jruby
JWRN
keepalive
lcs
leth
LGPL
MESSAGEBOX
Minitest
mmc
mtime
Nailgun
nathanael
nathanaeljones
ncpu
nokogiri
optparse
outputsize
portile
ramdisk
rcov
redhat
REGEXPS
rspec
RTEST
Rubocop
rubyforge
rvm
SDK
shortname
Shoulda
simd
Sqr
TESTUNIT
tmpfs
toolkits
unpackhi
unpacklo
WIDTHx
winmgmts
zedzone
zucchi
"');
next if /^($re)(?:$| .*)/;
print;' > $remove_obsolete_words
chmod +x $remove_obsolete_words
for file in .github/actions/spell-check/whitelist/54b3b066a6b4654f7e7a02e49e56a1b3c1c76c25.txt .github/actions/spell-check/whitelist/5ae660e58f0dca219d9dd5801aeffa0e4ad6e8fa.txt .github/actions/spell-check/whitelist/618f622b0f99f2500bd3dc383f7a2cef48b72e76.txt .github/actions/spell-check/whitelist/c5b95641888e2ab165141518065246c44002e236.txt .github/actions/spell-check/whitelist/e4840f3eb751a28d6a885096045c6f437a5e7000.txt .github/actions/spell-check/whitelist/whitelist.txt; do $remove_obsolete_words $file; done
rm $remove_obsolete_words
(
echo "
ative
jpegtinysize
msbuild
untimes
"
) | sort -u -f | perl -ne 'next unless /./; print' > new_whitelist.txt && mv new_whitelist.txt '.github/actions/spell-check/whitelist/0859c3bf2abc4d7651115c782f331a3c80710361.txt'
✏️ Contributor please read this
  • You can probably just add items into .github/actions/spell-check/whitelist/whitelist.txt.
  • If you need to use a specific token in one place and it shouldn't generally be used, you can
    add an item in .github/actions/spell-check/patterns.txt.

⚠️ Reviewers

At present, the action that triggered this message will not show its ❌ in this PR unless the branch is within this repository.
Thus, you should make sure that this comment has been addressed before merging this PR.

Please sign in to comment.