Create a png with transparency from eps

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
geroldboehler

Create a png with transparency from eps

Post by geroldboehler »

Hi all,

i am converting a eps to a png with the following commandline:

Code: Select all

convert -profile profiles/cmyk/EuropeISOCoatedFOGRA27.icc gaga.eps -profile "profiles/rgb/sRGB Color Space Profile.icm" -colorspace rgb gaga.png
everything works great - except that the png does have an white background.

this is what -verbose tells me:

Code: Select all

"/usr/local/bin/gs" -q -dQUIET -dPARANOIDSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=pam" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -g787x158  "-sOutputFile=/var/folders/E3/E3CQT-OcEZ4WUSfdij6U9E+++TI/-Tmp-/magick-bfVC5d1S" "-f/var/folders/E3/E3CQT-OcEZ4WUSfdij6U9E+++TI/-Tmp-/magick-TxNr8HsW" "-f/var/folders/E3/E3CQT-OcEZ4WUSfdij6U9E+++TI/-Tmp-/magick-LQaYYv0z"
/var/folders/E3/E3CQT-OcEZ4WUSfdij6U9E+++TI/-Tmp-/magick-bfVC5d1S PNM 787x158 787x158+0+0 8-bit ColorSeparation DirectClass 486kb 
gaga.eps PS 787x158 787x158+0+0 8-bit ColorSeparation DirectClass 486kb 
profiles/cmyk/EuropeISOCoatedFOGRA27.icc ICC 1x1 1x1+0+0 8-bit DirectClass 544kb 
profiles/rgb/sRGB Color Space Profile.icm ICM 1x1 1x1+0+0 8-bit DirectClass 3.07kb 
gaga.eps=>gaga.png PS 787x158 787x158+0+0 8-bit TrueColor DirectClass
so i tried the gs commandline by itself but instead of using -sDEVICE=pam i used -sDEVICE=pngalpha. i got a png with transparency, but it looked weird, probably because it didn't convert properly from the cmyk to the rgb profile. and i couldn't really find a way to tell gs to use profiles to convert...

did anybody here manage to properly convert a cmyk eps to a rgb png with profiles?
i uploaded the eps file here.

thanks and regards

gerold
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Create a png with transparency from eps

Post by magick »

We're using ImageMagick 6.5.2-1 and we get a white background as expected with these commands:
  • convert gaga.eps -colorspace rgb gaga.png
    display gaga.png
You can also try
  • convert -colorspace rgb gaga.eps gaga.png
    convert gaga.eps -profile profiles/cmyk/EuropeISOCoatedFOGRA27.icc -profile "profiles/rgb/sRGB Color Space Profile.icm" gaga.png
If its fails it could be a version problem with either of ImageMagick or Ghostscript.
geroldboehler

Re: Create a png with transparency from eps

Post by geroldboehler »

Hi magick,

i also get a white background - but i would like it to be transparent :)
i'm using

Version: ImageMagick 6.5.1-0 2009-05-06 Q8 http://www.imagemagick.org

and

GPL Ghostscript 8.64 (2009-02-03)
Copyright (C) 2009 Artifex Software, Inc. All rights reserved.

this is my output.

thanks!
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Create a png with transparency from eps

Post by magick »

This seems to work:
  • convert -verbose -colorspace rgb gaga.eps gaga.png
We hope that someday Ghostscript will have a device that supports up to 5 channels for RGB, RGBA, CMYK, and CMYKA at different depths (e.g. 4, 8, 16, etc.). Until then ImageMagick cannot render CMYKA Postscript images.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create a png with transparency from eps

Post by fmw42 »

i also get a white background - but i would like it to be transparent
You can also post-process the result (if you have no other white in the image):

convert image.png -fuzz XX% -transparent white image_transparent.png
geroldboehler

Re: Create a png with transparency from eps

Post by geroldboehler »

i just tried that fmw42 and it seems to work in my example, but i would really like to have a general sollution -
and somehow i just can't imagine that i'm the first person trying to properly convert a eps to a transparent png - or am i? ;)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Create a png with transparency from eps

Post by fmw42 »

geroldboehler wrote:i just tried that fmw42 and it seems to work in my example, but i would really like to have a general sollution -
and somehow i just can't imagine that i'm the first person trying to properly convert a eps to a transparent png - or am i? ;)

I don't believe that IM convert alone will make an image that has no transparency into one that has certain regions transparent. But I am not an expert on eps files or converting them. Have you looked at:

http://www.imagemagick.org/Usage/formats/#eps

Perhaps there some option, there.
geroldboehler

Re: Create a png with transparency from eps

Post by geroldboehler »

@magick:

convert -verbose -colorspace rgb gaga.eps gaga.png

indeed gives me a png with transparent background - but i would like to provide a input and a output profile so i get the colors right.

Code: Select all

convert -verbose -colorspace rgb gaga.eps -profile "profiles/rgb/sRGB Color Space Profile.icm" gaga.png
this gives me a transparent rgb png with the srgb profile embedded. but to get the colors right i would need to also provide a cmyk profile as input profile - and if i do that photoshop complains about a corrupt file. i think the problem is that the pngalpha device just outputs a rgba png without considering a input profile - probably because it only supports 4 channels. - otherwise it could output a cmyka png and then IM could convert it properly...

so basically it's a ghostscript problem - am i right?

thanks for helping!
Post Reply