PDA

View Full Version : Here is a photo resizing script for the mac user



Tim Morton
04-26-2008, 5:45 AM
I was looking for a simple script that i could drag and drop a picture onto and it would resize and save the picture with a new name. Here is is, I have it set to 720p wide, but you can change that number to any number you want. To make the application just open script editor and paste this in and then save as an application....throw it in your dock and presto.:) (copy and paste everything below)

-- save in Script Editor as Application
-- drag files to its icon in Finder

on open some_items
repeat with this_item in some_items
try
rescale_and_save(this_item)
end try
end repeat
end open


to rescale_and_save(this_item)
tell application "Image Events"
launch
set the target_width to 720
-- open the image file
set this_image to open this_item

set typ to this_image's file type

copy dimensions of this_image to {current_width, current_height}
if current_width is greater than current_height then
scale this_image to size target_width
else
-- figure out new height
-- y2 = (y1 * x2) / x1
set the new_height to (current_height * target_width) / current_width
scale this_image to size new_height
end if

tell application "Finder" to set new_item to ¬
(container of this_item as string) & "scaled." & (name of this_item)
save this_image in new_item as typ

end tell
end rescale_and_save

John Shuk
04-26-2008, 2:43 PM
What would you have to set it to so it will set pics up for this forum?

Tim Morton
04-26-2008, 3:13 PM
I haven't tried that yet...lets see if it works as is:

edit: a little small...I would try changing 720 to 900 and see.

Jim Becker
04-26-2008, 9:07 PM
Tim, I generally use 640 pixels wide for forum display, although a little larger will not hurt for most folks' browsers these days. The idea is to avoid forcing anyone to scroll left/right when an image gets too large for the post window in the browser.