• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Need help with image events droplet to save multiple files as png
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need help with image events droplet to save multiple files as png


  • Subject: Re: Need help with image events droplet to save multiple files as png
  • From: kai <email@hidden>
  • Date: Tue, 3 Jan 2006 03:29:24 +0000


On 3 Jan 2006, at 01:35, Michael Cytrynowicz wrote:


Can someone help me with something that must be embarassingly simple, but is giving me a hard time?
I am trying to write a droplet which saves multiple files as png (in the same folder as the original images). I think I'm getting stuck in passing the path information for where Image Events has to save the new file...

[snip]

==============

on open these_items
repeat with i from 1 to the count of these_items
set this_item to item i of these_items
set the item_info to info for this_item
set this_path to (item i of these_items) as string
set the new_path to (((characters 1 thru -4 of this_path) as text) & "png")
process_item(this_item)
end repeat

end open


on process_item(this_item)
	tell application "Image Events"
		launch
		set thisImage to open this_item
		scale thisImage to size 300
		save thisImage as PNG in file new_path with icon
		close thisImage
	end tell

==============

You're almost there, Michael.

Besides the information about 'this_item', your process_item handler also needs to know about 'new_path' - which is defined in the open handler, too. Try something like this (untested - since it's way past my bedtime, but with one or two other suggested tweaks thrown in):

-------------------

on open these_items
	repeat with this_item in these_items
		set this_path to this_item as Unicode text
		set new_path to text 1 thru -4 of this_path & "png"
		process_item(this_item, new_path)
	end repeat
end open

on process_item(this_item, new_path)
	tell application "Image Events"
		launch
		set thisImage to open this_item
		scale thisImage to size 300
		save thisImage as PNG in new_path with icon
		close thisImage
	end tell
end process_item

-------------------

Another way to do it might be to leave most of the work to the process_item handler:

-------------------

on open these_items
	repeat with this_item in these_items
		process_item(this_item)
	end repeat
end open

on process_item(this_item)
	set new_path to text 1 thru -4 of (this_item as Unicode text) & "png"
	tell application "Image Events"
		launch
		set thisImage to open this_item
		scale thisImage to size 300
		save thisImage as PNG in new_path with icon
		close thisImage
	end tell
end process_item

-------------------

---
kai


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Need help with image events droplet to save multiple files as png (From: Michael Cytrynowicz <email@hidden>)

  • Prev by Date: Setting dates in iPhoto...
  • Next by Date: Re: Need help with image events droplet to save multiple files as png
  • Previous by thread: Need help with image events droplet to save multiple files as png
  • Next by thread: Re: Need help with image events droplet to save multiple files as png
  • Index(es):
    • Date
    • Thread