Background color loss from EPS to other formats

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Carter J
Posts: 116
Joined: 2013-12-19T02:20:09-07:00
Authentication code: 6789

Background color loss from EPS to other formats

Post by Carter J »

Hi All,

We have few EPS images and while converting them to any other format say for ex: JPEG the background color is lost and is showing up white.

Attached is one eps image which has a back ground and in the other screenshot we can see after converting it to JPEG the back ground is showing up white

Any insight ?


https://www.dropbox.com/s/mdpcm4jc1wkbx ... psFile.eps
https://www.dropbox.com/s/lbe1b43bo6w1931/EpsToJPG.jpg

Version: ImageMagick 6.8.7-4 2013-10-26

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

Re: Background color loss from EPS to other formats

Post by snibgo »

If you "identify -verbose SampleEpsFile.eps" you will see it has a clipping path, which IM ignores by default. See http://www.imagemagick.org/script/comma ... s.php#clip

However, when I try for example "convert SampleEpsFile.eps -clip -negate t.png" I get:

Code: Select all

convert.exe: image size differs `sampleepsfile.eps' @ error/image.c/SetImageClipMask/2398.
snibgo's IM pages: im.snibgo.com
Carter J
Posts: 116
Joined: 2013-12-19T02:20:09-07:00
Authentication code: 6789

Re: Background color loss from EPS to other formats

Post by Carter J »

Hi snibgo,

Thanks for reply.

I tried convert SampleEpsFile.eps -clip -negate t.png, and got below image without any warnings or errors.

https://www.dropbox.com/s/de6kjz8x82uxlzr/t.png

Please suggest how can I get desired output without any background color loss.

Thanks,
Carter J
Posts: 116
Joined: 2013-12-19T02:20:09-07:00
Authentication code: 6789

Re: Background color loss from EPS to other formats

Post by Carter J »

Guys,
Any workaround on this would be of great help, as we are stuck with this kind of images.
Last edited by Carter J on 2014-01-29T23:18:49-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Background color loss from EPS to other formats

Post by fmw42 »

I am not sure what you mean by loss of background. All I see is a bit of aliasing on a white background. Your input eps file also seems to display with a white background. You can remove the aliasing by using supersampling

This does that by a factor of 4 (density 4*72=288 and resize 25%) while converting to sRGB jpg so that viewers do not have trouble with cmyk jpgs.

Code: Select all

convert -density 288 SampleEpsFile.eps -profile /Users/fred/images/Profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/Profiles/sRGB.icc -resize 25% SampleEpsFile2.jpg
If you want more antialiasing try using -density 576 and -resize 12.5%, ie factor of 8 in supersampling. You will have to locate your profiles on your system or download them. But I believe there is a folder in the IM download that has profiles.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Background color loss from EPS to other formats

Post by fmw42 »

Note that jpg does not preserve transparency. So you get a black background, but when it is converted to sRGB it turns white.

Also png does not support cmyk.

This works just fine for me (IM 6.8.8.4 Q16 Mac OSX Snow Leopard with ghostscript 9.06) to keep the transparent background in a png, by converting to sRGB. The best way is to use profiles (and supersampling) as

Code: Select all

convert -density 288 SampleEpsFile.eps -profile /Users/fred/images/Profiles/USWebCoatedSWOP.icc -profile /Users/fred/images/Profiles/sRGB.icc -resize 25% SampleEpsFile2.png
But a quick convert works in this way, though has aliasing artifacts

Code: Select all

convert -colorspace sRGB SampleEpsFile.eps SampleEpsFile3.png
but has aliasing artifacts, so again use supersampling

Code: Select all

convert -colorspace sRGB -density 288 SampleEpsFile.eps -resize 25% SampleEpsFile4.png
Post Reply