enlarging a image to the maximum height without loss of details

I would like the enlarged image to keep the same name as the original, and I will use Save As…

Here is the Script:

– Open the Applescript Editor.
– Create a new script and paste the following code:
on open theImages
repeat with anImage in theImages
tell application “Image Events”
–Set the maximum dimension of the picture.
– If it is in landscape mode, it is the width.
– If it is in portrait mode, it is the height.
set the targetSize to 1080
set currentImage to open anImage
set imageType to currentImage’s file type
scale currentImage to size targetSize
tell application “Finder” to set newImage to (container of anImage as string) & " " & (name of anImage)
save currentImage in newImage as imageType
end tell
end repeat
end open
– Save the script as an “Application”.
–Drag your image to the new script Application. You will get a new file with the new dimension.

Thank you for your help.

Hello

Here is a commented/edited version.

-- Open the Applescript Editor.
-- Create a new script and paste the following code:
on open theImages
	repeat with anImage in theImages
		tell application "System Events"
			set newImage to (path of container of anImage) & space & name of anImage
		end tell
		do shell script "cp " & quoted form of POSIX path of anImage & space & quoted form of POSIX path of newImage
		
		tell application "Image Events"
			--Set the maximum dimension of the picture.
			-- If it is in landscape mode, it is the width.
			-- If it is in portrait mode, it is the height.
			set the targetSize to 1080
			set currentImage to open newImage
			set imageType to currentImage's file type
			scale currentImage to size targetSize
			
			save currentImage
			close currentImage
		end tell
	end repeat
end open
-- Save the script as an "Application".
--Drag your image to the new script Application.  You will get a new file with the new dimension.

As you see, it doesn’t use the Finder and it duplicate the file before asking ImageEvents to apply.
If I remember well you already asked about this script.
We can’t guarantee that ImageEvents will do the job without loss.
In fact, I’m quite sure that you will loose details because doing the job with PhotoShop or The Gimp gives a better result, maybe because they use more recent algorithms.

Yvan KOENIG (VALLAURIS, France) mardi 9 septembre 2014 15:37:21

Hi,

In the other post, I showed part of the library script from Shane Stanley for enlarging the image. The new image looks pretty good. All you need to do to scale the image is:

  1. Check the image height and width.
  2. Find the ratio of the larger one to your desired scale size.
  3. Pass the new dimensions to the library script.

You now have a scaled image that looks ok to me.

gl,
kel