Graphic Converter Batch File

Is anyone familiar with calling a batch file from GraphicConverter into their script?

I need help with this. :?

Thx!

–Mac-Ker

Acronyms and initials are ok if everyone knows what they stand for - otherwise they suck. You might get better advice if you let everyone know which GC you are referring to. :slight_smile:

– R

GC = GraphicConverter

sorry there :smiley:

–Mac-Ker

No prob. :slight_smile:

I don’t see anything about batch files in GraphicConverter’s AppleScript dictionary but the manual does mention that the batch feature is available only if GC is registered.

– Rob

See I just did an update on GraphicConverter to 4.7.1, but it’s not registered unfortunately. :? Hmmm…

–Mac-Ker

I mean I was able to create a batch file and put it onto my desktop, so I just need to find a way to call that batch in my script. It’s a grayscale batch.

–Mac-Ker

I know nothing about batch files but I wonder what would happen if you ran this.

tell application "GraphicConverter"
	open alias "path:to:batch:file"
end tell

It opens the file and shows all the images, but it also shows the resources from “Batch”. :?

This is what I have:

on open pic_file
	repeat with image_ in pic_file
		tell application "GraphicConverter"
			set image_ to open pic_file
			--Changes the image to gray
			tell window 1
				open alias "path:to:batch:file"
				--Resizes the images and saves it in another folder
				scale horizontal 0.5 vertical 0.5
			end tell
		end tell
	end repeat
end open

–Mac-Ker

I didn’t think it would work but it was worth a shot. I have no other bright ideas. :?

– Rob

No worries. I’ll just try something else. :wink:

–Mac-Ker

Is there some reason why you can’t include the stuff done by the batch file in the repeat loop and forget the batch file altogether?

on open pic_file
	repeat with image_ in pic_file
		tell application "GraphicConverter"
			set image_ to open pic_file
			--Changes the image to gray
			tell window 1
				set color space to grayscale
				--Resizes the images and saves it in another folder
				scale horizontal 0.5 vertical 0.5
				save as
			end tell
		end tell
	end repeat
end open

That was my original code but it results in an error. :?

I mean it will open all the images files at one time, but it won’t change all of them to gray at the same time. So I was thinking maybe a batch file would help, but it doesn’t look like that will help. :? I’m just trying to find another way to change all these images at the same time without having to manually open them one by one.

My other script makes me manually do this:

set pic_file to (choose file with prompt "Select the image file to be opened")
tell application "GraphicConverter"
	set this_image to open pic_file
	--Changes the image to gray
	tell window 1
		set color space to grayscale
		--Resizes the images , changes it to TIFF and saves it in another folder
		scale horizontal 0.5 vertical 0.5
		save as
	end tell
end tell

I’m starting to hate GraphicConverter.

–Mac-Ker

Does this work? In your examples, there is a ‘save as’. This requires additional paramters, such as ‘save as PICT’. The following (untested) should just save the changes in the existing file.

on open pic_file
	repeat with image_ in pic_file
		tell application "GraphicConverter"
			set image_ to open pic_file
			--Changes the image to gray 
			tell window 1
				set color space to grayscale
				--Resizes the images and saves it in another folder 
				scale horizontal 0.5 vertical 0.5
			end tell
			close image_ saving yes
		end tell
	end repeat
end open

– Rob

I did have “save as TIFF” but that oddly didn’t do anything. :? So that’s why I just put “save as” so the user could change it manually to TIFF. Maybe it’s just me. :shock:

–Mac-Ker

Ok, you made me break down and test it. :stuck_out_tongue:

The problem is that opening the file does not return a result. This means that the variable ‘image_’ is empty. The following appears to work but!.. if you are opening files with an extension such as .jpg, the script will save as tiff but not change the name accordingly. It won’t take much to overcome this if the rest of the script works as desired.

on open pic_files
	tell application "GraphicConverter"
		repeat with image_ in pic_files
			try
				open (image_ as text)
				set win to (a reference to front window)
				--Changes the image to gray 
				tell win
					set color space to grayscale
					--Resizes the images and saves it in another folder 
					scale horizontal 0.5 vertical 0.5
				end tell
				save win as TIFF
				close win
				
			on error e
				display dialog e
			end try
		end repeat
	end tell
end open

– Rob

Well I tried it and it came up saying that it couldn’t set “window 1 to grayscale”. Hmm…

–Mac-Ker

It works for me using GraphicConverter v4.7.1. Maybe it depends on the type of image or its characteristics. I have little knowledge about images so I can’t offer much.

Thx for your help though. :smiley:

–Mac-Ker