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?
After you have recorded and saved your script in PhotoPaint, open the script file (.csc) with Notepad and delete the line of code that begins with SetDocumentInfo... and then resave. Now it should work on any size image. On Windows 7 saved scripts are located here:
C:\Users\YOUR USERNAME\AppData\Roaming\Corel\CorelDRAW Graphics Suite X7\PHOTO-PAINT\scripts
Patti
pranderson said:After you have recorded and saved your script in PhotoPaint, open the script file (.csc) with Notepad and delete the line of code that begins with SetDocumentInfo... and then resave. Now it should work on any size image.
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: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?
The following script works if you want a particular width. It will respect aspect ratios. Change the p# and the first number after Image Resample to match the desired width. Note: The two 72 numbers is dpi/resolution and TRUE is anti-aliasing on.
WITHOBJECT "CorelPHOTOPAINT.Automation.17"
h& = .GetDocumentHeight() w& = .GetDocumentWidth() p# = 250 / w h = h * p .ImageResample 250, h, 72, 72, TRUEEND WITHOBJECT
------------
Reverse the values if you want a particular height:
WITHOBJECT "CorelPHOTOPAINT.Automation.17" h& = .GetDocumentHeight() w& = .GetDocumentWidth() p# = 250 / h w = w * p .ImageResample w, 250, 72, 72, TRUEEND WITHOBJECT
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?
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.