newbie - batch convert .eps line drawings to best format

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
rtayek
Posts: 3
Joined: 2011-01-12T15:44:08-07:00
Authentication code: 8675308

newbie - batch convert .eps line drawings to best format

Post by rtayek »

hi, i have a bunch of .eps files that are line drawings (black and white). i am trying to figure out how to convert batches of them to a web data format (.gif, .png, .jpeg). these images will go into ebooks for ereaders and smart phones.

i can batch convert these files to these data formats using the mogrify command. but the results are not very good (lots of gray in .png format, varying line thickness in jpeg format, and a black background in .gif format).

using gimp, i discovered that when importing using the defaults (color) there was some alpha channel. flattening fixed this. importing as black and white and then just saving produced fairly good results. i have some examples (from gimp) at: http://tayek.com/bobt/epsimages/. the .gif and the .png seem to be the best. the .jpeg is gray and i assume that is because jpeg is a color format.

the gif files seems to be the smallest, so i am leaning in that direction.

can anyone give me an incantation that would let me specify the black and white colors when doing the mogrify (or perhaps there is a better command?).

any pointers will be appreciated.

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

Re: newbie - batch convert .eps line drawings to best format

Post by fmw42 »

try

mogrify -alpha off -colorspace gray -colors 2 -depth 1 -path /fullpath2anotherdirectory -format gif *.eps

but look at the mogrify docs for -path so you can save the results to another directory so you don't walk over your originals

see http://www.imagemagick.org/Usage/basics/#mogrify


I would try a few images manually using convert to test the commands and fine tune your -colors value and your -depth value before using mogrify

If you want to flatten rather than turning alpha off, then you need to specify a -background color and add -flatten after the -depth

Please experiment with convert before using mogrify
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: newbie - batch convert .eps line drawings to best format

Post by anthony »

-flatten will NOT work with morgify, as it is a multiple image or image sequence operator

use -bordercolor and -border 0 which will also 'flatten' images with mogrify.

see Removing Alpha Transparency
http://www.imagemagick.org/Usage/basics/#alpha_remove
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rtayek
Posts: 3
Joined: 2011-01-12T15:44:08-07:00
Authentication code: 8675308

Re: newbie - batch convert .eps line drawings to best format

Post by rtayek »

i tried convert using all combinations of

def csg="-colorspace gray"
def c2="-colors 2"
def bw="-background white"
def d1="-depth 1"
def fl="-flatten"
def ao="-alpha off"
def dt=" +dither"

you can see the results here: http://tayek.com/bobt/images/gif.html.

nothing seems to come close to what gimp does when importing in black and white.

thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: newbie - batch convert .eps line drawings to best format

Post by anthony »

The question is more. how nice do you want the results?

Direct conversion of EPS is not particularly nice. You can improve things by converting it at a higher resolution then resizing.

Examples of this and for setting/changing background nicely is
http://www.imagemagick.org/Usage/text/#postscript

The greys can be important to generate a smooth looking 'anti-aliased' output.


ASIDE: Are you setting up a 'Go' site? I haven't played the game for a while but I do have a little bit on my personal website. The Game displayed is actually one that terminated as me and the other player lost interest. The game was played by email and often took months to finished a single game. PS: I was white!
http://www.ict.griffith.edu.au/anthony/ ... ibrary/go/
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rtayek
Posts: 3
Joined: 2011-01-12T15:44:08-07:00
Authentication code: 8675308

Re: newbie - batch convert .eps line drawings to best format

Post by rtayek »

> The question is more. how nice do you want the results?

i would like them to be at least as good as gimp does, which is the first pic at http://tayek.com/bobt/images/gif.html.

> Direct conversion of EPS is not particularly nice. You can improve things by converting it at a higher resolution then resizing.

yes, i have done that and gotten some improvements.

> Examples of this and for setting/changing background nicely is
> http://www.imagemagick.org/Usage/text/#postscript

thanks for the link

> ASIDE: Are you setting up a 'Go' site? ...

no, a friend is translating go material from japanese and producing some ebooks - i am doing the technical stuff.

thanks
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: newbie - batch convert .eps line drawings to best format

Post by anthony »

Then reading at a higher density and resize to preserve the anti-alias information is what you need.
Study the link given, and let us know how you go.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply