1

Can anybody share an applescript which uses the pngquarnt to optimize images in a folder. May be even an Apple service be useful.

Note: There is an terminal command to do the same thing, but i am talking about a newbie, who can just right click on an folder containing images and optimize them.

object2.0
  • 891
  • 1
  • 12
  • 12

2 Answers2

1

This will process all png files in the folder that you select:

set myFolder to POSIX path of (choose folder)
set myFiles to do shell script "find " & quoted form of myFolder & " -name *.png -print0 | xargs -0 usr/local/bin/pngquant"

EDIT Hamdullah's answer uses the following line which is very similar to my response:

find $@ -name '*.png' -exec pngquant -ext .png -speed 1 -force 256 {} \;

However, xargs is preferable to exec when processing large batches of files. It is faster because When you use "-exec", it starts a new process for each file that is found

adayzdone
  • 11,120
  • 2
  • 20
  • 37
  • this looks good but i am accepting the other answer. As it is more easy for a newbie (especially non tech people). Anyway thanks for the effort. – object2.0 Dec 07 '12 at 06:12
  • You're welcome. I edited my response to give you a bit more bachground. – adayzdone Dec 07 '12 at 12:55
1

Download the zip from the bellow path and follow the steps from readme https://github.com/hamdullahshah/Automator-App-for-PngQuant

You can change the arguments by changing the command in "PngCompression WorkFlow" and then save it as application.

Hamdullah shah
  • 804
  • 5
  • 15