Skip to main content
Known Participant
August 17, 2012
Question

Cropping different file sizes script

  • August 17, 2012
  • 2 replies
  • 3824 views

I'm trying to come up with a way to have an action and script that will let me crop an image to 8x10 or 5x7 for example. What happens though is that if the image is a different size (resolution wise) when the action stops to allow me to do the crop, the crop guides will be a different size (depending on the initial resolution of the action set up image) or location on the image causing me to move the handles to get it back in to the new image. I would like the have the crop guides centered over the image in proportion to whatever resolution the image is. Can this be done?

This topic has been closed for replies.

2 replies

JJMack
Community Expert
Community Expert
August 17, 2012

You should be able to create an action to do that using my Plug-in Script AspectRatioSelection. You can automate a center crop or set upa  a center selection that is transformed 180 degrees and the transform step  made interactive. Hitting enter will accept the current sselection. If you do not like te selection you can move and transform it. Holding the Shift ket will constrain the transform to its current Aspect Ratio once you commit the selection the action will then crop the image. Once cropped the action would then use my second Plug-in script LongSidePrintLength to set the images print DPI so the image will print the size you want without resampling it. These scripts are in my crafting action package.

Crafting Actions Package UPDATED Aug 14, 2012 Changed AspectRatioSelection Plug-in script added Path support.

Contains

Example

Download

JJMack
ocphotogAuthor
Known Participant
August 18, 2012

Thanks for the suggestions. I did figure out that I needed to set the rulers to % when I did the initial crop so that same % would apply to other size files. Works fine now.

ocphotogAuthor
Known Participant
August 19, 2012

As I wrote the action to do center crops that require no user intervention are very easy to record in fact they are all identical with the exception that the two plug-in script steps need to be re-recorded to change the settings the step uses. The action is all of three steps so its just as easy to record a whole new action.

Step 1 menu File>Automate.AspectRatioSelection

Step 2 menu Image>Crop

Step 3 menu File>Automate>LongSidePrintLength

The plug-in scripts are based on Adobe plug-in "Fit Image"   You need not worry about the images orintation, All you need do is record two numbers for the ratio like 4 5.   If the current image is a portrait image the script creates a 4:5 aspect ratio selection if its a landscape it will create a 5:4 selection. All you need to do is record the aspect ratio you want to crop the image to.    Size does not matter. For example 8"x10", 4"x5" and 16"x20" all have an image aspect ratio of 4:5.

Once you have the image cropped to the correct aspect ratio  you then need to set its print DPI to the correct setting so it will print the size you want.

get it???

You can make the action interactive to allow you a chance to move and resize the selection set by the plug-in while maintaing its aspect ratio by holding the shift key down during the interactive transform selection to constrand the transform to its current aspect ratio. That requites a fourth step you record a transform selection step that rotates the selection 180 degrees after the first step in the action before the crop step. After the action is recoeded you turn on the transform selection step's doialog to make the action interactive.

The reason you rotated the selection 180 degrees is that you want to changes the selection not the area selected.  That way if the selection set by the script is acceptable all you need do is hit enter. If the action did not rotate the selection 180 degrees and the selection was acceptable and you hit enter that would cancel the transform and the action would stop at the transform step..

That is also interresting for that means if you mess up while modifying the selection transform you can press ESC and stop the action in the transform selection step.  You can the click Play in the actions palette and retry doing the transform selection correctly.

Message was edited by: JJMack

Message was edited by: JJMack


I must be doing something wrong because I'm not getting the results I hoped for using your method. Here is what's happening.

1. run script AspectRatioSelection - set it to 800x1000

2. marching ants show on image in correct aspect ratio.

3. If I rotate it 180 deg. it turns the selected image portion upside down.

3a. If I do Ctrl-T it reduces or enlarges the image, not the way I want to crop the image.

3b. If I have the Marquee tool selected I can move the marching ants up or down but nothing else.

What I would like to do is to be able to adjust the selection in or out to change what will be cropped. Can't seem to do that with the marguee tool.

Also, on the setting for the LongSidePrintLength. I'm assuming if I'm doing an 8x10 that I would make that setting 10?  I'm comfused when you say DPI, I'm thinking 300 dpi. so I think I'm supposed to have another step in the action to change the dpi to 300?

What am I missing?

Thanks!

Thanks!

c.pfaffenbichler
Community Expert
Community Expert
August 17, 2012

Mind sharing a few more details or the Script you currently use?

ocphotogAuthor
Known Participant
August 17, 2012

Sure,

The action does a fit to screen then calls the 8x10 crop.js to determing if it's a vertical or horizontal image.

8x10 crop.js:

if (activeDocument.width > activeDocument.height)

doAction("Horizontal","Crop to 8x10 Format.atn");

else if (activeDocument.width < activeDocument.height)

doAction("Vertical","Crop to 8x10 Format.atn");

this script runs the action for vert or horiz with crop tool set at 8x10 with no resolution set. Where it get placed on the image varies depending on the original size the image is since it could have been based on an older cameras file size at the time the action was made.

It's pretty basic I guess.