Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for professional graphic designers and non-designers trying to do their own graphic design. It's 100% free, no registration required.

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.

share|improve this question
    
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. –  Alex Blackwood Nov 12 '13 at 19:29
    
Isn't ImageMagic cross-platform? Could you provide an example? –  MikkoP Nov 12 '13 at 19:58
    
Sure, check my answer below. –  Alex Blackwood Nov 12 '13 at 20:20
add comment

1 Answer

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
share|improve this answer
    
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? –  Gramps Nov 12 '13 at 21:23
    
No, the -resize switch respects the input image's aspect ratio. The -extent switch then creates the padding, if needed. –  Alex Blackwood Nov 12 '13 at 21:37
    
+1 I was unaware of the -extent switch –  Gramps Nov 12 '13 at 21:42
    
It says no images defined output.png. See full error log: pastebin.com/mAmhqW6Y –  MikkoP Nov 13 '13 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. –  Alex Blackwood Nov 13 '13 at 16:21
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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