Broken gradients

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
stockphotos
Posts: 24
Joined: 2018-06-17T12:09:46-07:00
Authentication code: 1152

Broken gradients

Post by stockphotos » 2018-06-17T12:18:06-07:00

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/

Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Broken gradients

Post by Bonzo » 2018-06-17T12:40:11-07:00

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

User avatar
fmw42
Posts: 24121
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Broken gradients

Post by fmw42 » 2018-06-17T13:15:00-07:00

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

Bonzo
Posts: 2970
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Broken gradients

Post by Bonzo » 2018-06-17T14:11:32-07:00

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.

stockphotos
Posts: 24
Joined: 2018-06-17T12:09:46-07:00
Authentication code: 1152

Re: Broken gradients

Post by stockphotos » 2018-06-18T05:25:09-07:00

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!

snibgo
Posts: 10952
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Broken gradients

Post by snibgo » 2018-06-18T05:38:52-07:00

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.
snibgo's IM pages: im.snibgo.com

stockphotos
Posts: 24
Joined: 2018-06-17T12:09:46-07:00
Authentication code: 1152

Re: Broken gradients

Post by stockphotos » 2018-06-18T09:26:50-07:00

Sorry, meant to write:
convert -density 300 -colorspace sRGB xxxx.eps final.jpg

stockphotos
Posts: 24
Joined: 2018-06-17T12:09:46-07:00
Authentication code: 1152

Re: Broken gradients

Post by stockphotos » 2018-06-18T09:27:07-07:00

how do I change it to a 16 bit channel?

snibgo
Posts: 10952
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Broken gradients

Post by snibgo » 2018-06-18T09:57:11-07:00

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.
snibgo's IM pages: im.snibgo.com

stockphotos
Posts: 24
Joined: 2018-06-17T12:09:46-07:00
Authentication code: 1152

Re: Broken gradients

Post by stockphotos » 2018-06-18T10:17:22-07:00

Would you guys be so kind and help us come up with a solution?

User avatar
fmw42
Posts: 24121
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Broken gradients

Post by fmw42 » 2018-06-18T10:25:03-07:00

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.

User avatar
fmw42
Posts: 24121
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Broken gradients

Post by fmw42 » 2018-06-18T10:29:36-07:00

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.

snibgo
Posts: 10952
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Broken gradients

Post by snibgo » 2018-06-18T10:38:22-07:00

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.
snibgo's IM pages: im.snibgo.com

User avatar
fmw42
Posts: 24121
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Broken gradients

Post by fmw42 » 2018-06-18T10:44:48-07:00

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.

Post Reply