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”

11 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

  5. Your style is very unique in comparison to other people I have read stuff from.
    Thank you for posting when you have the opportunity, Guess I’ll just book mark this page.
    Summer

    Comment by Summer — October 17, 2012 @ 7:47 pm | Reply

  6. Hi there, just became alert to your blog through Google, and found that it is truly informative.
    I am gonna watch out for brussels. I’ll be grateful if you continue this
    in future. Lots of people will be benefited from your writing.
    Cheers!

    Comment by google.com — May 19, 2014 @ 5:45 pm | Reply

  7. Awesome, thanks for that script!

    Comment by sarouchkabarelier — April 21, 2015 @ 7:58 pm | Reply

  8. Thanks for this tidy little script, ideal for converting all of my Castalia PostScript graphs 🙂

    Comment by Brian Lawes — November 9, 2016 @ 4:31 am | Reply

  9. That’s great! Thank you very much! 🙂

    Comment by Anthoula — May 4, 2017 @ 2:38 pm | Reply

  10. This is exactly what I needed, you saved me a lot of time. Many thanks!

    Comment by santiagodelpa — May 24, 2017 @ 12:44 pm | Reply


RSS feed for comments on this post. TrackBack URI

Leave a reply to sarouchkabarelier Cancel reply

Blog at WordPress.com.