Page 1 of 1

Broken gradients

Posted: 2018-06-17T12:18:06-07:00
by stockphotos
Hi, When ImageMagic converts an EPS file to JPEG that has a gradient to 300 DPI, the gradients breakup. Please see sample attached. Your help would be highly appreciated. Thanks!

https://postimg.cc/image/eghx94ptt/

Re: Broken gradients

Posted: 2018-06-17T12:40:11-07:00
by Bonzo
For a useful reply you should add these details to your post:
Your Imagemagick version
The code you are using
OS/platform
Link to the original image

Re: Broken gradients

Posted: 2018-06-17T13:15:00-07:00
by fmw42
Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown

Re: Broken gradients

Posted: 2018-06-17T14:11:32-07:00
by Bonzo
I thought I had seen a similar post to this a few years ago but can't find it.

What does it look like if you save it as a png for example as jpg compression may have an effect also jpg does not has as large a range of colours.

Re: Broken gradients

Posted: 2018-06-18T05:25:09-07:00
by stockphotos
Imagemagick version: 6.8
The code we are using: PHP CLI
OS/platform: Linux
Command we use for this: convert -density 300 -colorspace sRGB converted_image.jpg sunrise.eps
Link to the original image: https://www.dropbox.com/s/edf4ty7ywogbv ... 6.eps?dl=0

Thank you very much for your help!

Re: Broken gradients

Posted: 2018-06-18T05:38:52-07:00
by snibgo
stockphotos wrote:convert -density 300 -colorspace sRGB converted_image.jpg sunrise.eps
That command reads a JPEG file and writes an EPS file, which is the opposite to your OP question.

If you are actually writing to a JPEG file, then JPEGs are only 8 bits/channel, which will show banding in subtle gradients. A 16 bit/channel format would be better.

Re: Broken gradients

Posted: 2018-06-18T09:26:50-07:00
by stockphotos
Sorry, meant to write:
convert -density 300 -colorspace sRGB xxxx.eps final.jpg

Re: Broken gradients

Posted: 2018-06-18T09:27:07-07:00
by stockphotos
how do I change it to a 16 bit channel?

Re: Broken gradients

Posted: 2018-06-18T09:57:11-07:00
by snibgo
JPG is always 8-bit. Other formats such as PNG and TIFF can be 16-bit.

However, converting your image always makes 8-bit. I don't know why. It also uses spot colours, which won't be converted (because Ghostscript ignores them). The result also has transparency, which will be ignored when writing JPEG.

Re: Broken gradients

Posted: 2018-06-18T10:17:22-07:00
by stockphotos
Would you guys be so kind and help us come up with a solution?

Re: Broken gradients

Posted: 2018-06-18T10:25:03-07:00
by fmw42
Change your output to PNG or (non-jpeg compressed) TIFF with a Q16 compile of ImageMagick. As snibgo has said JPG is 8-bit and any 8-bit output may show banding in gradients due to the limited color depth.

Re: Broken gradients

Posted: 2018-06-18T10:29:36-07:00
by fmw42
When I download your file and examine it (identify -verbose), it shows as PDF, not EPS, even thought it has an EPS suffix. Perhaps that is the issue. If you really have an EPS file, then perhaps zip compress it and upload it again. We need to have a proper input. When I display your image, it has banding in it already.

Re: Broken gradients

Posted: 2018-06-18T10:38:22-07:00
by snibgo
I'm not an expert on EPS (or PDF) files, but I think the banding is built into the file. It seems to be a feature of the image, not something that ImageMagick (or any software) will remove.

Re: Broken gradients

Posted: 2018-06-18T10:44:48-07:00
by fmw42
You can mitigate the amount of banding by rendering at a higher density and then resizing. try

Code: Select all

convert -density 1200 -units pixelsperinch 74296.eps -resize 25% tmp.jpg
If you also want to convert to srgb, then

Code: Select all

convert -density 1200 -units pixelsperinch -colorspace sRGB 74296.eps -resize 25% tmp.jpg
Or use 2 profiles in place of -colorspace srgb, but put them after the input image.