looking for quicker image events script

Hi everyone,

I need a script to resize some pics, the displayed below is the one I have which works, but it seems a little slow, about 9 seconds an image, I was wondering if there is something I can do to speed it up.

any and all help greatly appreciated

tell application "Finder"
	set holdingfolder to choose folder
	set destination_folder_lowres to "Macintosh HD:Users:iMac_G5:Desktop:outfolder:Low res:"
	set destination_folder_highres to "Macintosh HD:Users:iMac_G5:Desktop:outfolder:High res:"
	
	set these_files to every file of the holdingfolder
	tell application "Image Events"
		launch
		repeat with i from 1 to the count of these_files
			set this_path to (item i of these_files) as string
			set thisimage to open file this_path
			save thisimage in destination_folder_highres as JPEG
			scale thisimage to size 600
			save thisimage in destination_folder_lowres as JPEG
			close thisimage
			
		end repeat
	end tell
end tell

I don’t know how big your image files are, but if they are 10s of megapixels then that might explain why Image Events is so slow. I tried the following script using iMagine Photo with 4 megapixel images and it took less than a second to process each file.


on run
	tell application "Finder"
		set holdingfolder to choose folder
		set destination_folder_lowres to "Macintosh HD:Users:iMac_G5:Desktop:outfolder:Low res:" as alias
		set destination_folder_highres to "Macintosh HD:Users:iMac_G5:Desktop:outfolder:High res:" as alias
		set theFiles to every file of folder holdingfolder
		set theNum to the number of items in theFiles
		repeat with i from 1 to theNum
			set item i of theFiles to item i of theFiles as alias
		end repeat
	end tell
	
	tell application "iMagine Photo"
		repeat with i from 1 to theNum
			set thisImporter to import graphic (item i of theFiles)
			if component error of thisImporter is equal to 0 then
				tell thisImporter
					make exporter with properties {export file type:"JPEG"}
					set the export folder location to destination_folder_highres
					set the export file name to the file name
					export
					set the export folder location to destination_folder_lowres
					my ScaleToSize(thisImporter, 600)
					set the export file name to the file name
					export
				end tell
			end if
			close thisImporter
		end repeat
	end tell
end run

on ScaleToSize(theImporter, scaleTo)
	tell application "iMagine Photo"
		set {x, y, width, height} to the natural bounds of theImporter
		if width < height then
			set width to (width * scaleTo div height) as integer
			set height to scaleTo
		else
			set height to (height * scaleTo div width) as integer
			set width to scaleTo
		end if
		set the destination rectangle of theImporter to {0, 0, width, height}
	end tell
end ScaleToSize

You can download iMagine Photo from:

http://www.yvs.eu.com/downloads/iMaginePhoto.dmg

Kevin