Page 1 of 1
"-distort resize" followed by "-flatten" causes a strange 2px border
Posted: 2015-12-18T10:00:04-07:00
by sas
This command:
Code: Select all
convert netscape: -distort resize 100x100! -flatten x.png
Results in this image for me:
Note the image size of 102x102, and a 2px green border on the bottom and right egde.
When I run the same command with "
-resize" instead of "
-distort resize", I get a 100x100 image without border:
I would have expected both commands to produce a 100x100 image without border.
Why is
-distort resize behaving differently, and how can I prevent it?
(I prefer to use
-distort resize because of the better result quality, especially when upscaling.)
ImageMagick version:
6.9.2-6 Q16 x86_64 2015-12-06, on Linux.
Re: "-distort resize" followed by "-flatten" causes a strange 2px border
Posted: 2015-12-18T10:51:32-07:00
by magick
Remove the virtual canvas:
- convert netscape: -distort resize 100x100! +repage -flatten x.png
Re: "-distort resize" followed by "-flatten" causes a strange 2px border
Posted: 2015-12-18T11:07:29-07:00
by sas
That seems to work in my case, thanks!
I'm still a little worried about the "-distort resize" behavior though, since I don't understand why it happens.
Re: "-distort resize" followed by "-flatten" causes a strange 2px border
Posted: 2015-12-18T17:20:38-07:00
by magick
The extra pixels come from the -flatten option, not -distort. The -flatten option respects any virtual canvas.
Re: "-distort resize" followed by "-flatten" causes a strange 2px border
Posted: 2015-12-19T07:58:29-07:00
by sas
But "-distort" is responsible for extending the virtual canvas in this strange way, isn't it?
Is it supposed to do that?
Re: "-distort resize" followed by "-flatten" causes a strange 2px border
Posted: 2015-12-19T09:14:36-07:00
by magick
The -distort resize option is a special case for distort, it does not extend the virtual canvas.
Re: "-distort resize" followed by "-flatten" causes a strange 2px border
Posted: 2015-12-19T12:15:19-07:00
by fmw42
.
I believe there is a problem with -distort resize. The resulting image virtual canvas is indeed 102x102+0+0 rather than 100x100+0+0.
Code: Select all
convert netscape: -distort resize 100x100! tmp.png
Fred-Weinhauss-Mac-mini:desktop fred$ identify -verbose tmp.png
Image: tmp.png
Geometry: 100x100+0+0
...
Page geometry: 102x102+0+0
...
Re: "-distort resize" followed by "-flatten" causes a strange 2px border
Posted: 2015-12-19T13:41:21-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.9.2-10 Beta, available by sometime tomorrow. Thanks.
Re: "-distort resize" followed by "-flatten" causes a strange 2px border
Posted: 2015-12-20T11:25:35-07:00
by sas
Good to know, thanks!