Page 1 of 1
mogrify EPS to PNG error
Posted: 2016-12-11T16:40:10-07:00
by ungovernable
I have 5000 vector images (mostly eps / svg) that i need to convert to PNG with transparent backgrounds. PNG images need to be maximum 4000x4000px
This command will work perfectly for SVG vector:
magick mogrify -resize "4000x4000" -transparent white -format png *.svg
For EPS vectors, i tried this:
magick mogrify -resize "4000x4000" -density 300 -transparent white -format png *.eps
The problem is that the output PNG image looks very bad quality and pixelisated
Even with 1200 density, here's how it looks compared to original :
Also, i'm getting weird error when running mogrify:
If i open the same EPS image in illustrator and convert it to SVG instead, save it in the exact same folder, then run the script with *.svg parameter, the output PNG looks good and there is no error... So it doesn't look like a path error, or an error with the graphic file... SVG are converted correctly, but not EPS
Re: mogrify EPS to PNG error
Posted: 2016-12-11T17:04:31-07:00
by snibgo
IM delegates the reading of EPS files to Ghostscript. You command shows that the Ghostscript command fails. Have you installed Ghostscript? If not, then that is the problem.
Re: mogrify EPS to PNG error
Posted: 2016-12-11T17:26:32-07:00
by ungovernable
Oh, i was told on graphic stackexchange that i didn't need to install Ghostscript.
I just installed it, the result is a little bit better but still blurry and the colors are messed up. On some images, the transparency didn't work.
Here's the original EPS image side-by-side with the output PNG:
https://gyazo.com/b6eb56e930891e600d7da3ad56a54d86
I tested with higher density
Code: Select all
magick mogrify -units PixelsPerInch -density 1200 -resize "4000x4000" -transparent white -format png *.eps
But it will just run forever and never output any image
Shouldn't be a resources problem, i have i7 4.4ghz 6950x (10-core) + 64gb ddr4 + GTX 1080 Titan X + 1tb SSD 960 Pro
Re: mogrify EPS to PNG error
Posted: 2016-12-11T17:36:57-07:00
by snibgo
You don't say what programs you are using for the side-by-side comparison. You are resizing to 4000x4000, then again (I suppose) down to your screen size. So that might account for a "blurry" result.
Can you link to the actual EPS file?
Re: mogrify EPS to PNG error
Posted: 2016-12-11T17:57:19-07:00
by ungovernable
i'm just using the default windows preview to display the PNG image. it's not just a blur problem, but also colors and transparency. Even at 100% zoom it's blurry.
if i just open EPS in illustrator then export to PNG and do the same test, everything looks fine.
EPS:
https://ufile.io/ca6a4
PNG:
https://uploadfiles.io/a3533
Re: mogrify EPS to PNG error
Posted: 2016-12-11T18:33:46-07:00
by snibgo
Converting that EPS with no density results in an image 350x455 pixels, at a resolution of 72 "undefined". Resizing that to 4000 looks horrible, of course.
Using "-density 720" before the EPS input isn't at all blurry.
The EPS file has spot colours. These are special inks, used when CMYK isn't good enough. Ghostscript gives you an approximate colour for these.
You can get other approximations by extracting:
Code: Select all
exiftool -ThumbnailImage -b ca6a4-go_green16.eps >x.jpg
exiftool -TiffPreview -b ca6a4-go_green16.eps >x.tiff
Re: mogrify EPS to PNG error
Posted: 2016-12-11T19:40:53-07:00
by ungovernable
Using density parameter doesn't work for me, no PNG image will be rendered even if i let it run during 5 minutes, nothing happen, it just stay stuck forever on this screen:
https://gyazo.com/60c7488e710787d4ab4fe8f5fb2a2457
The EPS file has spot colours. These are special inks, used when CMYK isn't good enough. Ghostscript gives you an approximate colour for these.
I have thousands of files to convert and can't check them all manually. If i take the EPS file with "spot colours" and save it as SVG in illustrator, then use imagemagick to convert it to PNG everything looks fine ! Why does it works with SVG but not EPS ? I guess i should just try to find a way to convert my EPS to SVG then i could convert them automatically to PNG ?
Re: mogrify EPS to PNG error
Posted: 2016-12-11T21:24:24-07:00
by snibgo
The spotcolours have names like:
Code: Select all
ps:SpotColor-0: procset Adobe_CoolType_Utility_T42 1.0 0
I suppose Adobe Illustrator knows the closest RGB or CMYK approximation.
Code: Select all
magick mogrify -density 720 -units pixelsperinch -resize 4000x4000 -transparent White -format png ca6a4-go_green16.eps
This takes 5.5 seconds on my Windows 8.1 laptop, 12 GB ram, far less power than your computer.
EDIT: IM v7.0.3-6, GS 9.19.
Re: mogrify EPS to PNG error
Posted: 2016-12-11T22:00:35-07:00
by ungovernable
I tried other EPS files and the PNG were successfully created, however i'm still having problems...
Background is white opaque even if original EPS file had transparent backgrounds. I tried both with and without parameter -transparent white
Also the quality is totally terrible, here's how it looks with an EPS file with a lot of details
(png on left, original EPS on right)
even in 1200dpi it looks awful
Here's the EPS file i'm testing with (original stock image)
https://ufile.io/8889a
Re: mogrify EPS to PNG error
Posted: 2016-12-11T23:01:43-07:00
by snibgo
In CMYK, to make white pixels transparent, use "-transparent CMYK(0,0,0,0)". IM colour names assume the channels are RGB, so you would need "-transparent Black".
I don't know much about EPS files, but 8889a-evolution-of-the-concept-of-greening-of-the-world-5.eps seems to contain a lot of raster data as well as vector data. Perhaps Ghostscript is picking this up. I don't know.