Skip navigation
ocphotog
Currently Being Moderated

Cropping different file sizes script

Aug 17, 2012 5:57 AM

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?

 
Replies
  • Currently Being Moderated
    Aug 17, 2012 7:38 AM   in reply to ocphotog

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

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 17, 2012 1:18 PM   in reply to ocphotog

    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

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 18, 2012 10:47 AM   in reply to ocphotog

    I happy you found something that  works for you.  You stated " 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." Are you using a action that uses a script if so are you seting ruler units to % for the action or the script or both. 

     

    How does percentage help with making aspect ratio crops. I would think Percent would only work if all your image had the same aspect ratio and orintation to begin with.  If you have images that have different aspect ratios I think your Action + Script might have some poblems. 

     

    For examp images from point and shoot cameras have aspect ration 4:3 and perhaps wide ones 16:9 where image from DSLR have a 3:2 aspect ratio. Also some images are in portrait orintation and some are in landscape orintation.  You may have also cropped some images to an unknown aspect ratio. Are you sure you have tested your solution well???

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 18, 2012 6:06 PM   in reply to ocphotog

    Actually I'm wrong more the I'm right for I can not type and make more errors the the average bear. 

     

    If you download my cafteing actions package, It would be very easy to record actions to do 8x10, 4x5, 5x7 etc center crops that requires no user intervention. One action for each size you want to create.

     

    You could then with a single run of the Image Processor Pro plug-in script (found on Russell Brown's web site) create  8x10, 4x5, 5x7 images for all your images in an image tree. You just need to take a long cofee break while the script runs your images throught the corpping actions you have recorded.

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 18, 2012 6:57 PM   in reply to JJMack

    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

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 19, 2012 4:43 AM   in reply to JJMack

    Using the script to do the interactive Crop are requires one more action step then creating the interactive action without using the scripts. However two of the action steps need to be interactive where using the scrips onle the extra step needs to be interactive.

     

    The interactive action without scripting three steps.

     

    Step 1 rectangle marquee tool setetion mode set to ratio draged out a bit from uppet left corner

    Step 2 Image>Crop

    Step 3 Image Size resample not checked units set to inches

     

     

    Step 1 and Step 3 dialog are turned on.

     

    This single action can be used to do every crop you need but requires more work for two steps require intervention. Also the interactive marquee tool  step is a pain to use. You  need to set in the aspect ratio for all crops other then to ratio user recording the step. And the selection always needs to be draged out and positioned.

     

    Step 3 is easy to use you just neet to enter one sid length for Photoshop to set the DPI. Sitt its a required second user interventioj.

     

    Still its only one three step action the can always be used.

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 19, 2012 6:20 AM   in reply to ocphotog

    ocphotog wrote:

     

     

    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.

    Here is the story:

     

    1. run script AspectRatioSelection - set it to 800x1000

    800 1000 is the same as 8 10 same as 4 5 same as 5 4

    its just a ratio not pixels you can enter the ratio any way you care to

    and the script figures which orintation to use Portrait or landscapt.

     

    2. marching ants show on image in correct aspect ratio

    yes the script figures the pixel sizes from top left and has an option to center using the correct orintation

     

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

    You rotated the the pixels not the selection. Ctrl+t  rotates the area to rotate the selection use

    menu Select>Transform Selection

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 19, 2012 6:33 AM   in reply to JJMack

    I think you should read the text files in my crafting actions packege. I do not do text well but I work hard on those files. I tried to make them shortand packed full of good information.  They should make you think some ang give a lot of knowledge it took me years to fully understand.

     

    My Image Visulization package has an older version of AspectRatioSelection that does not have Path support I just added. I will Update the package.

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 19, 2012 7:11 AM   in reply to ocphotog

    300 DPI will work if you resample the image.  The  longsideprintlength will set the correct dpi resolution without resampling the document.

     

    In the crafting action package there is a sample watermarking action that can put a logo the correct size on any size image. The action dose this by using one of my utility scripts that is run twice. the first time it is run it records the document current dpi resolution. The action then changes the dpi resilution without resampling the image so it would print 8" wide. The action then placed in the logo the approate size for a 8" wide image and then positions the logo. The script is then run a second time the second time the script is run it retrieves the recorded dpi resolution and restores the document to that resolution. The net result is the image size is the same as it was to begin with and the logo has been sized to fit the images size.

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 19, 2012 7:22 AM   in reply to JJMack

    About the scripts in my crafting actions package.  All but the two Plug-in Scripts are small and should be easy to read.  You may gain a little knowledge if you read the source.  However remember I do not know javascript and object orientated programming. Once I was a programmer now I'm just a hacker. I fear if I did not hack some I would become senile.

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 19, 2012 8:02 AM   in reply to ocphotog

    Use Photoshop to position your logo where you want. Its simple with align layers to selection.   For example you can simply to a select all then modify the selection to contract is some so it will not touch the canvas edges. With the logo the targeted layer using menu "layer>Align Layers to Selection>xxx"  twice you can position you logo as though you were putting in on a tick tack toe board within the selection. The selection need not be the whole document.  I use it to position text on Images and position images in collages. The images are position to the center of alpha channels that are loaded as selection and added as layer mask. The Layer mask acts like a virtual crop and the text can be placed over the image in one of nine places.

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 19, 2012 8:16 AM   in reply to JJMack

    I hope your seeing the light. Use your eyes the see and read what features Photoshop has. Then use your brain when using Photoshop your brain now has the knowledge it need to do thing that would be inposible to do without the knowledge you have stored in it.

     

    I also do not think there is anything in this tread that is not in my crafting actions package.

    Sample Actions.txt Photoshop CraftedActions set saved as a text file.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points