Image Events... for what its worth

I have found that using image Events in side a loop to process many images was causing all kinds of memory problems.

In my script i was processing 5 images 67 times in a repeat

Im not a programmer but it seemed that Image Events did not clear it cache after each process therefore building a memory drain so much so that I was asked to quit applications for the script to run. memory usage was up to 4GB.
Hence during the repeat loop the process would start to slow and eventually stop

My workaround is this and still does not make much sense but at least works. You might have to adjust the delay accordingly with working with 1000’s images


tell application "Image Events"
		launch
		set this_image to open this_item
		scale this_image to size theResize
		save this_image as JPEG in saveFilePath with compression level medium with icon
		scale this_image to size theResize
		save this_image as JPEG in webFolder with compression level medium with icon
		close this_image
		quit
		delay 0.5
		launch
	end tell

don’t ask me why you have to quit and launch at the end within the same tell block but it does not work without it.

FWIW, this looks like a problem in the underlying frameworks, not Image Events itself, and one that has been fixed in Mavericks.

Hi weedinner,

I suggest you to use sips. Image Events is based on SIPS but sips is CLI and probably is much faster.
You can call it using do shell script.
I use it every day processing tons of PDF and TIFF files (PDF are rasterized in CMYK with GhostScript and after color managed and saved as JPEG with SIPS) on ASOC app that runs on 10.6.8 Mac Mini server.
I never had problem of memory. Very very reliable.

Stefano - Ame

Image Events does much the same as sips, and I don’t know that there’s a lot of difference in their performance. But because you call sips as a separate process, the memory is automatically released after every call. That can make a big difference.

Didn’t Shane Stanley post examples about manipulating images? They were very quick also. I haven’t delved into that lately but you should add some of those modules to your library.

gl,
kel

Just tried in Mavericks Shane and still not fixed. For it to work now I had to take out the final launch


tell application "Image Events"
       launch
       set this_image to open this_item
       scale this_image to size theResize
       save this_image as JPEG in saveFilePath with compression level medium with icon
       scale this_image to size theResize
       save this_image as JPEG in webFolder with compression level medium with icon
       close this_image
       quit
       delay 0.5

   end tell

Probably nothing to do with your problem, but apart from setting your file variables, is that the full script? You don’t need to scale the image twice to the same amount. And the name of your variable ‘webFolder’ suggests you’re trying to save the image to a folder instead of to a file.

Hi Nigel

No its not the full script and you are quite correct that I don’t need to scale the image twice. Missed that in the panic I had to put this script together initially.

The variables are indeed file paths.