Page 1 of 1
EPS with clipping path convert to png with transparent background
Posted: 2017-08-06T22:47:10-07:00
by janebrandhub
hi,
I am new to imagesmagick and try to convert EPS with clipping path to png. The png should only have image with transparent background. I searched forum and found some similar topics using script:
convert -colorspace "sRGB" input.eps -alpha "transparent" -clip -alpha "opaque" output.png
When i apply this script, the -clip removes image rather than background. So the output.png becomes a white with nothing on it.
I also tried
convert input.eps +clip-path "#1" -alpha "transparent" output.eps
I get the same result. Can anyone help me? I am using IM-7.0.5-Q16 and Ghostscript 9.21.
Re: EPS with clipping path convert to png with transparent background
Posted: 2017-08-06T23:28:55-07:00
by fmw42
In IM 7 you need to use magick in place of convert. See
viewtopic.php?f=3&t=31924&p=146061&hilit=clip#p146049. The bug was fixed in IM 7.0.5.6. So depending upon your 7.0.5.x version, you may need to upgrade Imagemagick.
For novices, see
viewtopic.php?f=1&t=9620http://http://w ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
Re: EPS with clipping path convert to png with transparent background
Posted: 2017-08-08T14:49:09-07:00
by janebrandhub
Thank you. I have upgraded to IM 7.0.6 and clip works on eps file. But the converted png file has very jagged edge. Is any way i can make it better?
Re: EPS with clipping path convert to png with transparent background
Posted: 2017-08-08T16:43:38-07:00
by fmw42
Can you upload your EPS file to some place such as dropbox.com and put the URL here so we can test with it. If not, then try
Code: Select all
convert -density 288 input.eps +clip-path "#1" -alpha "transparent" -resize 25% output.eps
or just leave the -resize 25% out.
Re: EPS with clipping path convert to png with transparent background
Posted: 2017-08-08T22:50:44-07:00
by janebrandhub
I tried your script and get the same jagged edge. My current script is:
magick -density 300 -depth "8" -colorspace "sRGB" input.eps -alpha "transparent" -clip -alpha "opaque" -resize "400x400" output.png
I also try to add -fuzz 1% -fill none but no luck.
I don't have dropbox account. My eps file is about 40MB. Any other way i can send eps through?
Re: EPS with clipping path convert to png with transparent background
Posted: 2017-08-08T23:37:24-07:00
by fmw42
Only way is if you have our own server and can upload there. Dropbox is free, so that is a good solution.
This works for me? Does it work for you?
http://www.fmwconcepts.com/misc_tests/c ... OV_EPS.eps
Code: Select all
convert -density 150 -colorspace sRGB 218755504_HOV_EPS.eps -alpha transparent -clip -alpha opaque -strip 218755504_HOV_EPS_im6.png
If that works, try
Code: Select all
convert -density 600 -colorspace sRGB 218755504_HOV_EPS.eps -alpha transparent -clip -alpha opaque -strip -resize 25% 218755504_HOV_EPS_im6_2.png
Why are you using +clip-path "#1"?
The + sign turns off that clip path. See
http://www.imagemagick.org/Usage/masking/#clip-path
Re: EPS with clipping path convert to png with transparent background
Posted: 2017-08-09T21:26:23-07:00
by janebrandhub
The script
convert -density 600 -colorspace sRGB 218755504_HOV_EPS.eps -alpha transparent -clip -alpha opaque -strip -resize 25% 218755504_HOV_EPS_im6_2.png
has better output than the first one. But the right edge of png image is better than the left and top edge. I also tried couple of my own eps images and got the same result. very interesting. Not sure how i fix the left and top edge issue.
What's the delegate libpng version included in the Windows IM 7.0.6-Q16? If i remove -strip, i get the error message:
"convert: profile 'icc': 'CMYK': invalid ICC profile color space @ warning/png.c/MagickPNGWarningHandler/1744."
If i use -strip, i can only get 72dpi png not 300dpi which i want.
Re: EPS with clipping path convert to png with transparent background
Posted: 2017-08-09T22:11:44-07:00
by janebrandhub
Re: EPS with clipping path convert to png with transparent background
Posted: 2017-08-09T22:44:50-07:00
by fmw42
This works for me on IM 6.9.9.5 Q16 and IM 7.0.6.5 Q16 HDRI Mac OSX and produces a transparent background PNG. If it works for you and you want an EPS output, then change the output suffix to .eps. (for IM 7 change convert to magick)
Code: Select all
convert -density 300 -units pixelsperinch -colorspace srgb test1.eps -alpha transparent -clip -alpha opaque -strip test1_output.png
Re: EPS with clipping path convert to png with transparent background
Posted: 2017-08-10T22:45:52-07:00
by janebrandhub
Thank you for the script. I know where is the jagged issue from. It's from -resize
If i do your script:
convert -density 300 -units pixelsperinch -colorspace srgb test1.eps -alpha transparent -clip -alpha opaque -strip test1_output.png
I get the good anti-aliased result, but if i want to resize png to certain size, i do:
convert -density 300 -units pixelsperinch -colorspace srgb test1.eps -alpha transparent -clip -alpha opaque -strip -resize 1000x1000 test1_output.png
I get the jagged edge. Looks like -resize causing the issue.
If i use pipe to get the output png,
"magick -density 300 -units pixelsperinch -colorspace srgb test1.eps -alpha transparent -clip -alpha opaque -strip PNG:- | magick - -resize 1000x1000 test1_output.png"
The jagged issue is gone.
Any other way i can fix this jagged issue without using pipe command? Since IM4Java needs bit more code to work out pipe thing.
Re: EPS with clipping path convert to png with transparent background
Posted: 2017-08-11T09:42:45-07:00
by fmw42
I do not see any aliasing with this command with the addition of -resize 1000x1000 using IM 6.9.9.5 Q16. But I do with IM 7.0.6.5 Q16 HDRI. That looks like a bug or an HDRI issue.
IM 6
Code: Select all
convert -density 300 -units pixelsperinch -colorspace srgb test1.eps -alpha transparent -clip -alpha opaque -strip -resize 1000x1000 test1_output2a.png
IM 7
Code: Select all
magick -density 300 -units pixelsperinch -colorspace srgb test1.eps -alpha transparent -clip -alpha opaque -strip -resize 1000x1000 test1_output2b.png
If you still have trouble, then you can antialias by blurring the edges of the alpha channel. Try
Code: Select all
magick -density 300 -units pixelsperinch -colorspace srgb test1.eps -alpha transparent -clip -alpha opaque -strip -resize 1000x1000 -alpha on -channel a -blur 0x3 -level 50x100% +channel test1_output3.png
Increase or decrease the 3 on -blur 0x3 as desired for more or less anti-aliasing.
However, you do point out that it does not occur if you pipe before resizing.
Code: Select all
magick -density 300 -units pixelsperinch -colorspace srgb test1.eps -alpha transparent -clip -alpha opaque -strip PNG32:- | magick - -resize 1000x1000 test1_output2c.png
Re: EPS with clipping path convert to png with transparent background
Posted: 2017-08-12T05:52:45-07:00
by magick
Re: EPS with clipping path convert to png with transparent background
Posted: 2017-08-13T16:41:02-07:00
by janebrandhub
Thank you all. This issue is resolved.