Page 1 of 1

Convert eps to png with transparent background

Posted: 2008-07-01T02:46:09-07:00
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

Re: Convert eps to png with transparent background

Posted: 2008-07-01T07:33:43-07:00
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.

Re: Convert eps to png with transparent background

Posted: 2008-07-01T10:15:12-07:00
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.

Re: Convert eps to png with transparent background

Posted: 2008-07-03T03:57:33-07:00
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

Re: Convert eps to png with transparent background

Posted: 2008-07-03T08:43:04-07:00
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.

Re: Convert eps to png with transparent background

Posted: 2008-07-03T08:57:31-07:00
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

Re: Convert eps to png with transparent background

Posted: 2008-07-07T07:05:21-07:00
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