I'am looking for a script that resize and keep the creation date like the original for numeric photo.
I write some code that work with only ONE PHOTO ! but doesn't if I drag more than one photo.
on open some_items
set the target_length to 640
display dialog "Enter the target length " & ¬
"and choose the dimension of the " & ¬
"image to scale to the target length:" default answer ¬
target_length buttons {"Cancel", "Height", "Width"}
copy the result as list to {target_length, target_dimension}
set the target_length to the target_length as number
repeat with this_item in some_items
tell application "Image Events"
launch
set theInfo to info for this_item
set newDate to the modification date of theInfo as date
-- open the image file
set this_image to open this_item
set typ to file type of this_image
copy dimensions of this_image to {W, H}
if the target_dimension is "Height" then
if W is less than H then
set the scale_length to the target_length
else
set the scale_length to (W * target_length) / H
set the scale_length to ¬
round scale_length rounding as taught in school
end if
else -- target dimension is Width
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 the scale_length to the target_length
end if
end if
scale this_image to size target_length
save this_image
close this_image
tell application "Finder" to set the modification date of this_item to newDate
end tell
end repeat
end open