3

I have about 280 Illustrator .ai files that I need to convert into .png files with a finished size of 500px x 500px. All of them aren't squared, so those that are, for example rectangular, need to be centered in the image and the background needs to be transparent.

Is there an easier way to do this because I wouldn't like to spend time converting them manually.

3
  • It depends on what operating system you're on. If you're comfortable with using the command line and can install Imagemagick, I recommend that. Commented Nov 12, 2013 at 19:29
  • Isn't ImageMagic cross-platform? Could you provide an example?
    – MikkoP
    Commented Nov 12, 2013 at 19:58
  • Sure, check my answer below. Commented Nov 12, 2013 at 20:20

1 Answer 1

2

If you have imagemagick installed, you can run the following command:

convert -colorspace RGB \
-background transparent \
-resize 500x500 \
-gravity center \
-extent 500x500 \
yourfile.ai outputfile.png

How you iterate over all files in a directory depends on your environment, of course, but something like this should work for bash:

for i in *.ai; do convert -colorspace RGB -background transparent -resize 500x500 -gravity center -extent 500x500 "$i" "$i.png"; done
7
  • That's a good solution but looking at your code wouldn't all the images have to be square and not rectangular because it will transform all the documents to 500px x 500px?
    – user9447
    Commented Nov 12, 2013 at 21:23
  • No, the -resize switch respects the input image's aspect ratio. The -extent switch then creates the padding, if needed. Commented Nov 12, 2013 at 21:37
  • It says no images defined output.png. See full error log: pastebin.com/mAmhqW6Y
    – MikkoP
    Commented Nov 13, 2013 at 10:12
  • Hmm. Looks like you're missing Ghostscript, which is required to interpret pdf files. If you do a search for Imagemagick Postscript delegate failed you should be able to find a solution. Commented Nov 13, 2013 at 16:21
  • I downloaded Ghostscript from this website. Now I get this error. pastebin.com/Xp3SixjK That path is correct. I tried it with forward slashes too, no difference.
    – MikkoP
    Commented Nov 13, 2013 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.