Converting EPS to PNG leaving black boarder around png

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
Maddox
Posts: 4
Joined: 2016-11-20T12:15:37-07:00
Authentication code: 1151

Converting EPS to PNG leaving black boarder around png

Post by Maddox »

When I am trying to convert a series of images from RGBA .eps to png and maintain the source file name. I am getting a black outline on output png. And I am not sure what is causing this.

The command that I am using is below:
convert -density 300 -colorspace RGB "C:\Users\Matt\Logos\*.eps" -background transparent -gravity center -scale 600x600 -extent 600x600 -set filename:original %t -colors 256 %[filename:original].png

Everything else seems to be working fine, but I am left with this strange barely visible boarder.

Any idea on whats causing this or how to fix it would be greatly appreciated.

Here are the output files:
http://imgur.com/a/klQ3C

Thanks!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Converting EPS to PNG leaving black boarder around png

Post by Bonzo »

And your IM version is?
Maddox
Posts: 4
Joined: 2016-11-20T12:15:37-07:00
Authentication code: 1151

Re: Converting EPS to PNG leaving black boarder around png

Post by Maddox »

Bonzo wrote:And your IM version is?
ImageMagick 7.0.3-0 Q16 x64
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting EPS to PNG leaving black boarder around png

Post by fmw42 »

Can you provide your input EPS file? We cannot test your command without it. Also what is your platform (presumed Windows from your syntax)? Please always provide your IM version and platform with any questions, since syntax may vary.

P.S. Why are you using linear RGB. That would make the image darker. You should be using -colorspace sRGB with current versions of IM.

The "border" around the figure is aliasing probably from the scaling. You would need to extract the alpha channel and blur it a bit to antialias the border edges of your figure. -scale is rather coarse. Perhaps you should try -resize.
Maddox
Posts: 4
Joined: 2016-11-20T12:15:37-07:00
Authentication code: 1151

Re: Converting EPS to PNG leaving black boarder around png

Post by Maddox »

Thanks for the response fmw42

Here is the link to one of the eps files I am trying to convert https://we.tl/uhixSjOCvw

Sorry for not providing my IM Version and platform. I'm running it on Windows 7 and ImageMagick 7.0.3-0 Q16 x64

So I tried the resize command vs the scale command and it seemed to help although the black border is still there. The sRGB vs RGB input definitely helped the color output. I was wondering what was going on there.

I will try to figure out how to extract the alpha channel and blur it slightly to get ride of that black border. Haven't tried this before so if anyone could point me in the right drirection many thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Converting EPS to PNG leaving black boarder around png

Post by fmw42 »

For a single image (windows syntax, I think), try

Code: Select all

magick -density 300 -colorspace sRGB 130.eps ^
-background transparent -gravity center -resize 600x600 -extent 600x600 ^
( +clone -alpha extract -blur 0x0.5 -level 50x100% ) ^
-alpha off -compose copy_opacity -composite ^
-set filename:original "%t" -colors 256 "%[filename:original]_3.png"
Try also -blur 0x1. See which looks better. You can also change the 50 in -level 50x100%.
Maddox
Posts: 4
Joined: 2016-11-20T12:15:37-07:00
Authentication code: 1151

Re: Converting EPS to PNG leaving black boarder around png

Post by Maddox »

Thanks fmw42, this works great for individual images, but what would I need change to convert a whole batch of eps files? Just changing the format to *.eps extension doesnt seem to do the trick.

Any advice or something I'm missing here?

magick -density 300 -colorspace sRGB "C:\Users\Maddox\Logos\*.eps" -background transparent -gravity center -resize 600x600 -extent 600x600 ( +clone -alpha extract -blur 0x0.5 -level 50x100% ) -alpha off -compose copy_opacity -composite -set filename:original "%t" -colors 256 [filename:original].png"

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

Re: Converting EPS to PNG leaving black boarder around png

Post by fmw42 »

You could try mogrify, but I am not sure it handles parenthesis processing. If not, then you will have to write a script loop over each eps image.
Post Reply