stumped

Okay this should be a piece of cake for all of you :slight_smile: How would I get this script to process…

A) by choosing multiple files?
or
B) as a droplet?

Is this something common, to edit script to be droplets or “multiple file choose” (interchangeably)?
How do you normally save your scripts?

set this_file to choose file without invisibles
set the target_length to 1200
try
	tell application "Image Events"
		--start the Image Events application
		launch
		--open the image file
		set this_image to open this_file
		--get dimensions of image
		copy dimensions of this_image to {W, H}
		--determine the shortest side and then
		--calculate the new height for the longer side
		if W is less than H then
			set the scale_length to (H * target_length) / W
			set the scale_length to ¬
				round scale_length rounding as taught in school
		else
			set scale_length to (W * target_length) / H
			set the scale_length to ¬
				round scale_length rounding as taught in school
		end if
		--perform action
		scale this_image to size scale_length
		--save the changes
		save this_image with icon
		--purge open image data
		close this_image
	end tell
on error error_message
	display dialog error_message
end try

I’m still getting my feet wet and I am not getting this.

thank you,

~N

You might be interested in this article: Getting the Drop on Droplets

Hi,

try this


on run
	set chosenFiles to choose file with multiple selections allowed without invisibles
	open chosenFiles
end run

on open theFiles
	set the target_length to 1200
	tell application "Image Events"
		--start the Image Events application
		launch
		--open the image file
		repeat with oneItem in theFiles
			try
				set this_image to open oneItem
				--get dimensions of image
				copy dimensions of this_image to {W, H}
				--determine the shortest side and then
				--calculate the new height for the longer side
				if W is less than H then
					set the scale_length to (H * target_length) / W
					set the scale_length to ¬
						round scale_length rounding as taught in school
				else
					set scale_length to (W * target_length) / H
					set the scale_length to ¬
						round scale_length rounding as taught in school
				end if
				--perform action
				scale this_image to size scale_length
				--save the changes
				save this_image with icon
				--purge open image data
				close this_image
			on error error_message
				display dialog error_message
			end try
		end repeat
	end tell
end open

Thank you! So Stefan, you’re version of this script acts as either a double-click or a droplet?

And that is achieved by this?:

on run
set chosenFiles to choose file with multiple selections allowed without invisibles
open chosenFiles
end run

~N

exactly