Convert eps to png with transparent background

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
CaptainFuture

Convert eps to png with transparent background

Post by CaptainFuture »

Hi folks!

I have got the following problem:
I want to convert an eps file to an png file and do a resize, but the background of the png file has to be transparent.
Maybe the the following code in php is wrong, but it does everything I want except the transparency:

Code: Select all

exec("convert -resize x283 -clip " . $eps . " " . $png);
Has anyone an idea or can help me?
Thanks.

See you
CaptainFuture
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Convert eps to png with transparent background

Post by Bonzo »

No idea about your problem but I would try something simple first and go from there e.g. change the eps to a png.

Any version over 6.0? you want to read the image in first and you should not need the " . - on my system you do not anyway :D

Code: Select all

exec("convert $eps $png");
It would also help others if you can give a path to the eps file so they can try it.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Convert eps to png with transparent background

Post by fmw42 »

try adding -channel RGBA

convert <image> -channel RGBA <output>


Otherwise, find out what color you are getting for the background and then add -transparent thatcolor before the output image.
CaptainFuture

Re: Convert eps to png with transparent background

Post by CaptainFuture »

@bonzo
Thanks for your answer.
I tryed the simple one first and converting is ok, but the background of the png is allways white.
The absolute server path is also checked an ok, because a new png file is created out of the eps.
Do I need special libs for the clip function?

Installed:
php 5.2.6-0
libpng12-0
libxml2
imagemagick 6.2.4.5
php5-gd 5.2.6-0
...


The eps file is ok and hase a path.
Here is a Link to the eps file:
http://tinyurl.com/5pbwh8

@fmw42
I tryed with your command -channel RGB but there is no difference to the normal convert.
How do you get the current backgroundcolor with of an image with imagemagick without knowing it before?

Thanks

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

Re: Convert eps to png with transparent background

Post by fmw42 »

try

convert <image> -channel RGBA -matte output

if that does not work then you can check the verbose info histogram to find the color under the transparent area if there is a transparent area

convert <image> -verbose info:

or convert <image> -format %c histogram:info:

(if I recall correctly)

Then the first 3 values are the r,g,b values and the fourth is the transparency. Transparency 0 is opaque and transparency 1 is fully transparent.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Convert eps to png with transparent background

Post by Bonzo »

I have just used identify on the image and get:
Background color: white
Border color: cmyk(223,223,223,0)
Matte color: grey74
Transparent color: black
CaptainFuture

Re: Convert eps to png with transparent background

Post by CaptainFuture »

Hi folks,

thanks for your help, but I have found the reason for the problem:
It's php 5.2.6-0, maybe a gd/xml lib in php.
With php 5.2.0-8 everything is fine.

See you
Captain Future
Post Reply