-- This is the last version I could find, modified 20060902. Don't even know if it works, let alone if it'd be useful. -- Requires potrace, imagemagick, and netpbm. Paths are from Fink, you may need to change them. -- Appears to compile ok in AppleScript Editor 2.3 on Mac OS 10.6.2 but has not been tested. on run display dialog "drag! drag! ok!" buttons "oh. right." with icon caution end run on open filelist set realsteps to getChoice("num of steps?", {"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "23"}, "5") + 1 -- levels of posterization in each channel set size1 to getChoice("first resize?", {"100", "200", "300", "400", "750"}, "200") -- resize all images to this size before adding borders and processing set size2x to getChoice("final image size?", {"320", "640", "800"}, "640") * 1.1 -- final image size set linewidth to getChoice("outline thickness?", {"0", "0.5", "1.0", "2.0", "3.0", "5.0"}, "0") -- outline thickness repeat with i in filelist set Ppath to POSIX path of i set stamp to do shell script "date ``+%Y%m%d.%H%M%S``" set bsuf to ".b.png" set suff to ".prb.svg" do shell script "/sw/bin/convert -normalize -bordercolor '#000000' -border 5% -resize " & size1 & "x" & size1 & " " & Ppath & " " & Ppath & bsuf repeat with c from 0 to 2 by 1 if c = 0 then set chan to "r" if c = 1 then set chan to "g" if c = 2 then set chan to "b" repeat with kstep from 0 to (realsteps - 1) by 1 set k to kstep / (realsteps - 1) set rk to (round (k * 100)) / 100 set antik to 1 - rk set ksuf to antik * 100 set lastk to (realsteps - 1) do shell script "/sw/bin/pngtopnm " & Ppath & bsuf & " | /sw/bin/pamchannel " & c & " | /sw/bin/pamtopnm -assume | /usr/local/bin/potrace -s -k " & antik & " -o" & Ppath & "." & stamp & "_" & chan & ksuf & suff set kgrey to antik * 256 if antik = 1 then set kgrey to 255 set rkgrey to round (kgrey) set khex to do shell script "printf '%X' " & rkgrey if c = 0 then set hex to khex & "ffff" if c = 1 then set hex to "ff" & khex & "ff" if c = 2 then set hex to "ffff" & khex do shell script "sed 's/#000000/#" & hex & "/' " & Ppath & "." & stamp & "_" & chan & ksuf & suff & " > " & Ppath & ".2." & stamp & "_" & chan & ksuf & suff -- color/vector style -- do shell script "sed 's/#000000/#" & khex & khex & khex & "/' " & ppath & "." & stamp & "_" & chan & ksuf & suff & " > " & ppath & ".2." & stamp & "_" & chan & ksuf & suff -- grey/bitmap style do shell script "sed 's/none\">/#000000\" stroke-width=\"" & linewidth & "\">/' " & Ppath & ".2." & stamp & "_" & chan & ksuf & suff & " > " & Ppath & ".3." & stamp & "_" & chan & ksuf & suff if kstep ­ 0 then do shell script "sed -n '//p' " & Ppath & ".3." & stamp & "_" & chan & ksuf & suff & " >> " & Ppath & ".3." & stamp & "_" & chan & "100" & suff -- comment out next 2 lines if you want to keep stuff do shell script "rm " & Ppath & "." & stamp & "_" & chan & ksuf & suff do shell script "rm " & Ppath & ".2." & stamp & "_" & chan & ksuf & suff if ksuf ­ 100 then do shell script "rm " & Ppath & ".3." & stamp & "_" & chan & ksuf & suff end repeat end repeat repeat with xs from 0 to 2 by 1 if xs = 0 then set xchan to "r" if xs = 1 then set xchan to "g" if xs = 2 then set xchan to "b" do shell script "sed 's/<\\/svg>//g' " & Ppath & ".3." & stamp & "_" & xchan & "100" & suff & " >> " & Ppath & ".3." & stamp & "_" & xchan & "100x" & suff do shell script "echo \"\" >> " & Ppath & ".3." & stamp & "_" & xchan & "100x" & suff do shell script "/sw/bin/convert -background none " & Ppath & ".3." & stamp & "_" & xchan & "100x" & suff & " -resize " & size2x & "x" & size2x & " " & Ppath & ".3." & stamp & "_" & xchan & "100x" & suff & ".png" --comment next 2 lines if you want to keep vector stuff do shell script "rm " & Ppath & ".3." & stamp & "_" & xchan & "100" & suff -- do shell script "rm " & ppath & ".3." & stamp & "_" & xchan & "100x" & suff end repeat do shell script "/sw/bin/convert " & Ppath & ".3." & stamp & "_r100x" & suff & ".png" & " " & Ppath & ".3." & stamp & "_g100x" & suff & ".png" & " " & Ppath & ".3." & stamp & "_b100x" & suff & ".png" & " " & "-channel RGB -combine -shave 5% " & Ppath & ".png" --comment next 4 lines if you want to keep png stuff do shell script "rm " & Ppath & ".3." & stamp & "_r100x" & suff & ".png" do shell script "rm " & Ppath & ".3." & stamp & "_g100x" & suff & ".png" do shell script "rm " & Ppath & ".3." & stamp & "_b100x" & suff & ".png" do shell script "rm " & Ppath & bsuf end repeat end open on getChoice(promptText, choiceList, defaultChoice) set theChoice to (choose from list choiceList with prompt promptText default items defaultChoice OK button name "all right") -- If the Cancel button's clicked, generate a "User canceled." error to stop the script. if (theChoice is false) then error number -128 return theChoice end getChoice