Problem with -splice

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
fbingha

Problem with -splice

Post by fbingha »

Using 6.3.6 on Windows.

Source image is 933x73 JPEG

Command is:

Code: Select all

convert.exe -size 150x150 file.jpg -thumbnail "150x150>" -sharpen 0x1 -gravity South -background "#000000" -splice 0x15 -fill white -pointsize 11 -draw "text 0,0 '933x73 20kb JPEG'" -bordercolor "#000000" -compose Copy -border 1 -quality 75
Expected output is a thumbnail with a black border underneath with the original image dimensions. In reality the spliced section is not added to the image resulting in the text being applied over the image.

If you execute this with a 933x95 image then it works as expected with a black section at the bottom with the image dimensions. This bug has something to do with images that are very wide in comparison to their height as the above code has been used millions of times over the years to generate thumbnails without problems.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problem with -splice

Post by anthony »

The latest IM produces the correct output AFTER I added a output filename on the end of the command.

trying a 933x95 image --- good
trying 933x73 still good.
trying a very thin (height wise image -- bad...

definite bug happens when the height of the splice is larger than the height of the image having the splice added. the splice operation is in that instance no-op'd

here is a simplified example of the bug...

For example this works...

Code: Select all

convert -size 100x15 xc:red -gravity South -background "#000000" -splice 0x15  x:
this fails

Code: Select all

convert -size 100x15 xc:red -gravity South -background "#000000" -splice 0x16  x:
Removing -gravity South will make the splice work again, so it is probably a gravity calculation failure.
DEFINITE BUG
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
fbingha

Re: Problem with -splice

Post by fbingha »

Glad that you are able to reproduce it. Definitely happens for me with the 933x73 image that was submitted to me with the bug from a customer. Do you know of any way to workaround this bug, still achieve -gravity south?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problem with -splice

Post by anthony »

replace -gravity South -splice 0x15
with -flip -splice 0x15 -flip
OR use -border 0x15 -chop 0x15
with border color instead of background color
For more info see IM Examples, Cutting and Bordering

Note you will need to set -gravity South after the above but before -draw or better still -annotate the text
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply