I am trying to record a script that will resize pictures of varying sizes to a particular dimension, in this case, 1920 pixels wide. Any ideas how I can do this?
If I use "resample" to resize a photo to the desired size, and record that action as a script, the resulting script will only work on other images that are the identical size of the image I used when recording the script. How can I write a script that will resize images to the same width, regardless of their original size?
RoyReed said: This only works if all the images are the same aspect ratio. Does anyone a way to do this for a batch of images of different aspect ratios to always resize to longest edge to the same pixel dimension?
This only works if all the images are the same aspect ratio. Does anyone a way to do this for a batch of images of different aspect ratios to always resize to longest edge to the same pixel dimension?
RoyReed said:Thanks Patti I have a batch of 300 random photos from a client to rescale. I don't really want to go through them to sort the portrait from landscape ones - which I think I'd have to do (if I understand your scripts correctly).
Actually, it will do what you want -- and it will respect the aspect ratio/proportions. The problem was my wording when I described it was wrong. I have edited my post to correct that.
If you want a particular width use the first script.
If you want a particular height use the second script.
I used the first script on the following images. They were various sizes and one was portrait orientation. They now have a 250 px width, but their proportions stayed true.
Patti
Okay. I think I still was confused about what Roy was after. Good thing I don't write scripts for a living!
The following script should resize the width of landscape oriented images to the specified size. If the image orientation is portrait, it will change the short side to the specified size. Just change 250 to whatever the width is needed, and change the dpi's (72) to what you want.
-------------------------
WITHOBJECT "CorelPHOTOPAINT.Automation.17" h& = .GetDocumentHeight() w& = .GetDocumentWidth()
IF h > w THEN p# = 250 / h w = w * p .ImageResample w, 250, 72, 72, TRUE
ELSE p# = 250 / w h = h * p .ImageResample 250, h, 72, 72, TRUE END IFEND WITHOBJECT
---------------------
It worked for me, but perhaps someone could test it and see if it works for them?