Page 1 of 1

-rotate jpeg leaves jagged edges

Posted: 2017-09-27T12:01:50-07:00
by Zelf
You can see that -rotate 22 ends up with jagged edges.

Image

Code: Select all

convert treefrog.jpg -background transparent -rotate 22 -antialias -resize 340x440 -gravity Center -background transparent -extent 350x450 treefrog.rotated.png
How do I get rid of the jagged edges?

If I convert to png it is fine, but I want the resultant image to be jpeg.

Image

Re: -rotate jpeg leaves jagged edges

Posted: 2017-09-27T12:31:46-07:00
by fmw42
Please post your input image and (always) provide your IM version and platform.

Note: PNG supports transparency and thus 8-bit alpha (for antialiasing the boundary). JPG does not support alpha.

-antialias does nothing in this command. Try flattening against black first. You also need to add +repage after the rotate to remove the virtual canvas.

Code: Select all

convert treefrog.jpg -background transparent -rotate 22 +repage -resize 340x440 -gravity Center -background transparent -extent 350x450 -background black -flatten result.jpg

Re: -rotate jpeg leaves jagged edges

Posted: 2017-09-27T12:36:20-07:00
by snibgo
When an image has transparency but you want to save it as JPEG, which can't record transparency, I suggest you explicitly flatten it first, eg "-background Black -layers flatten". This will keep the anti-aliasing.

If you don't flatten it, IM will simply remove the alpha channel, creating jaggies.

Re: -rotate jpeg leaves jagged edges

Posted: 2017-09-27T12:37:22-07:00
by Zelf
@fmw42, I knew I should put my info in there. Missed it in my haste to post problem.

ImageMagick 6.9.1-9

Original image: Image

Your command worked. Thank you.

@snibgo, thank you for the understanding I was lacking. I get it now.

Re: -rotate jpeg leaves jagged edges

Posted: 2017-09-27T12:38:53-07:00
by fmw42
See my command above.