RESOLVED:possible bug -compose displace / -extent IM6896

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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

RESOLVED:possible bug -compose displace / -extent IM6896

Post by fmw42 »

I have a strange bug that might relate to -compose displace or -extent where the background is not being filled properly unless I add +write PNG:null:


This relates to my trying to compress the code from my cylinderize script into a new script that does not recreate the displacement map each time.

I have simplified the code as far as I can and still reproduce the issue.

input image:
Image

displacement map image:
Image


This code fails to fill the background completely with black and keeps some transparency.

Code: Select all

convert -respect-parenthesis \
\( "img5967.jpg" +repage -gravity center -background none -extent 149x224 \
-resize 93.9691x100% -background black -gravity west -extent 149.591x224 \) \
"displace.png" -virtual-pixel black -background black -gravity northwest \
-define compose:args=9.57656x112 -compose displace -composite test3c.png
Image


This code works fine so long as I add +write PNG:null: (it does not work if I use +write MIFF:null)

Code: Select all

convert -respect-parenthesis \
\( "img5967.jpg" +repage -gravity center -background none -extent 149x224 \
-resize 93.9691x100% -background black -gravity west -extent 149.591x224 +write PNG:null: \) \
"displace.png" -virtual-pixel black -background black -gravity northwest \
-define compose:args=9.57656x112 -compose displace -composite test4c.png

Image


Am I missing some setting that needs to be reinitialized to its default?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: possible bug -compose displace / -extent IM 6.8.9.6 Q16

Post by snibgo »

With IM v6.8.9-5 Q16 integer on Windows 8.1, your first command gives a result close to your desired result. RMSE 0.06, ie 6% difference. Your second command fails with:

Code: Select all

convert.exe: unable to open image `null:': Invalid argument @ error/blob.c/OpenBlob/2658.
convert.exe: WriteBlob Failed `null:' @ error/png.c/MagickPNGErrorHandler/1805.
With IM v6.8.9-6 Q32 HDRI, self-compiled on Cygwin, your first and second commands give identical results, even closer to your desired result (RMSE 0.001).
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug -compose displace / -extent IM 6.8.9.6 Q16

Post by magick »

Alpha channels are undefined by default. Add an opaque alpha channel to your displacement map with -alpha to initialize the alpha channel to a known value. Does that fix the problem?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug -compose displace / -extent IM 6.8.9.6 Q16

Post by fmw42 »

magick wrote:Alpha channels are undefined by default. Add an opaque alpha channel to your displacement map with -alpha to initialize the alpha channel to a known value. Does that fix the problem?
That fixed it. Thanks very much.
Post Reply