My software notes

January 26, 2006

convert all *.ps to PNG format by a script

Filed under: softwares and scripts — kpwu @ 2:59 am

  1. ONLY convert the files in the directory where this script is.
  2. “-density 150″ is the resolution, in this case 150 dpi
  3. -geometry 100% is the scale you want to resize by %
  4. also, you can convert lots of JPEG to smaller resolution, just change .ps to .jpg, and change the output to another directory, either using .jpg or .png

———— following lines are the content of the script ———

#!/bin/sh

########################
## using “convert” from ImageMagick to do ps convert into PNG
#########################

echo PS convert to PNG, please wait the process
for INP in *.ps
do
newname=`basename $INP .ps`
convert -density 150 -geometry 100% $INP $newname%02d.png
echo ” convert $INP to $newname.png completely”
done
echo ” process ended, please check your graphical files”

5 Comments »

  1. thanks mann..

    Comment by yag — May 31, 2009 @ 3:59 am | Reply

  2. It is not working for me.

    It displays:

    PS convert to PNG, please wait the process
    /c/Program Files/GRASS-64/bin/convert.sh: line 11: convert:
    command not found
    ” convert *.ps to *.png completely”
    ” process ended, please check your graphical files”

    Comment by Janine — March 20, 2011 @ 9:10 am | Reply

  3. I guess you are using MS Windows?
    I am not sure whether the UNIX shell tool sare fully supported (if you are using windows).
    The convert is a tool script provided by “ImageMagic” (http://www.imagemagick.org/script/index.php). You have to get this program installed.
    Also, i think the path of convert.sh under “program files” is a problem.

    Comment by kpwu — March 20, 2011 @ 3:34 pm | Reply

    • I already installed ImageMagick but it still did not work. Also, I tried running the script not from Program Files. It also did not work.

      Comment by Janine — March 21, 2011 @ 8:06 am | Reply

  4. great one, it works on my mac! thanks

    Comment by hossein — February 22, 2012 @ 11:35 am | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.