Skip to main content
MauMan
Inspiring
March 2, 2020
Answered

Fashion e-commerce AutoSelect Subject and Crop

  • March 2, 2020
  • 13 replies
  • 7592 views

Hi friends,

I'm looking for a script that detects a subject and crops the image.

 

Workflow

I get thousands of RAW files with a wide framing. Same camera all over the shooting, same pixel dimensions. Models move and change pose.

I develop on C1 and export PSD files.

Work on the PSD files and export JPEG for the client.

 

Script

Detect Model's height and crop leaving a few pixels above the head and bellow the feet.

Model should be centered on the image.

Keep aspect ratio 2:3.

 

Input files

https://www.dropbox.com/sh/gbufidhfqic1f4b/AADlTLSsfwDxTDBL-RcQHAxxa?dl=0

 

 

 

 

 

 

 

Thanks in advance!

This topic has been closed for replies.
Correct answer MauMan

Thanks all for your help!

After reading all the proposals I came out with an action. Please take a look at it and let me know your comments.

The action runs auto-select, expands the selection 35px, creates a filled temp layer, transforms and uses the trim command.

 

To keep the 3:2 proportion I considered the model's height:

Width = 0.667 × Height

Once the model's height is "mapped" by the autoselect command I just copy the selection, rotate 90° and contract the width to 66.7%.
Then trim transparent pixels on top, bottom, left and right.

 

Download:

Autocrop.atn 

 

13 replies

Earth Oliver
Legend
August 22, 2023

hey mods, there are multiple spam bots in this thread...

didiermazier
Community Expert
Community Expert
March 21, 2020

Rotating is a brillant idea!

Stephen Marsh
Community Expert
Community Expert
March 10, 2020

So maurom15189996 you now have at least two different methods to achieve your stated goal.

 

Any feedback, comments? Likes? Marking one or more posts as the Correct Answers?

MauMan
MauManAuthorCorrect answer
Inspiring
March 20, 2020

Thanks all for your help!

After reading all the proposals I came out with an action. Please take a look at it and let me know your comments.

The action runs auto-select, expands the selection 35px, creates a filled temp layer, transforms and uses the trim command.

 

To keep the 3:2 proportion I considered the model's height:

Width = 0.667 × Height

Once the model's height is "mapped" by the autoselect command I just copy the selection, rotate 90° and contract the width to 66.7%.
Then trim transparent pixels on top, bottom, left and right.

 

Download:

Autocrop.atn 

 

Stephen Marsh
Community Expert
Community Expert
March 21, 2020

Great job maurom15189996 I really like it, you have come up with a workable native solution and I too would have marked it as the correct answer!

Stephen Marsh
Community Expert
Community Expert
March 10, 2020

Hi didiermazier - OK, that works as far as it goes, however, it is resampling the images as a hack work-around to get to the 2:3 aspect ratio.  Now if you can come up with a method that does not resample, then that would be something! This is why I relied on scripting where necessary.

 

maurom15189996 did not specify that the images should be resampled/resized, however, if that is acceptable then the job is done.

 

My action cropped without resampling/resizing, which is why I had to use helper scripts to do the things that Photoshop can't do with native tools and recorded steps.

didiermazier
Community Expert
Community Expert
March 11, 2020

You are right and there is another issue with this lasr solution :

you have first to check max height of the smaller girl in order to find the propee measure for the resizing.

this is why I choose 3000 px to be sur that I would not alter the pics enlarging them.

relatîg to resampling you are facing two choices : resampling or get a variable margin up and down.

when you resample all models have the same height no matter mother nature… same size same margin.

and lasr since the pics are Jpeg I suppose their destination is Web. In this case 3000 px is way to much…

was interesting thread !

Participant
November 4, 2022

latest ladies fashion wears in uk wholesale dealer. get latest party wears, shirts, skirts, coats, tops and trousers. New stock available with different variants

Stephen Marsh
Community Expert
Community Expert
March 10, 2020

Exactly Didier!

 

When the only tool you have is a hammer, even a screw looks like a nail.

 

I too hope to learn something, there is a good reason for my action/helper script combo, but I could be missing something too. It would not be the first time that I have over thought something!

didiermazier
Community Expert
Community Expert
March 10, 2020

Hey I think I finally found a way to get all pics same size and 2:3 what ever the model height is…

Once the Select/enlarge/crop is done  the  trick is setting image size for the height and then setting canvas width.

Here is the video : CROP 3

Stephen Marsh
Community Expert
Community Expert
March 10, 2020
 

"I swear this is my last post on this thread!"

 

I don't want this to be your last post on this thread, please don't take my constructive criticism the wrong way either... There is a reason that I suggested the approach that I did.

 

Unfortunately the 2:3 ratio crop tool recorded in an action will record absolute pixel values and not the relative values entered into the toolbar:

 

 

I did try your second video, the action screenshot is above, so unless I misunderstood, the method resulted in uneven/incorrect crops... But they were 2:3 ratio! I tried Batch, Image Processor and Image Processor Pro all using the same action.

 

I'm with you, I wish that there was an easy way without scripting to do this using only native methods.

 

P.S. I missed your earlier ACR suggestion, and while a nice idea, each image is too variable – the subject is not in the same size/position each time and the result is inconsistent, even among the 5 sample images provided, let alone thousands.

didiermazier
Community Expert
Community Expert
March 10, 2020

I swear I will never swear!

Your critism is welcome because it makes me go further. We all are here to find solutions. 

In fact when checking what I proposed I found evident problems that I did not take in count at first time :

  • Models are not all the same size.
  • Phototshop action recording set up selections and cropping to fixed positions (top, left…) and not center and ratio.

I will work on a better action using doc size and the align for the crop frame.

Again I am not competing. All solutions are good to take!

Best

Didier

Stephen Marsh
Community Expert
Community Expert
March 8, 2020

Hi didiermazier I watched your video, however, I personally would not use or recommend that approach.

 

The content-aware scale method that you show took approx 52 seconds to run. It is all manual. Unless I am missing something, the image is destructively resampled.

 

The goal is to automate repetitive editing of 1000's of images.

 

My action/script based workflow takes around 8 seconds to run (on my computer, so YMMV faster or slower) and can be used in Batch/Image Processor/Image Processor Pro for unattended automation of many images. The result is a 2:3 crop without any resampling.

 

As the saying goes "to each their own".

didiermazier
Community Expert
Community Expert
March 9, 2020

This video just show the base process.

Then of course you will record this as an action and apply to your 1000 pics as well with the batch processor.

The idea was just to find an alternative way using photoshop native features without coding.

But you are right the exec time is longer for each pic. Time to take a break for instance.

😉

It occures to me another stupid no coding solution :

If your computer is strong enough open these images with  Camera Rawthen select all of them and apply the 2:3 croping to all of them in just one step

Then instead of opening them, just save and set up the new folder

And you are done

 

 

didiermazier
Community Expert
Community Expert
March 9, 2020

I swear this is my last post on this thread!

There is a definitively simpler way to achieve the 2:3 crop with PS native features

Here is a video showing the process (and action recording): CROP 2

  1. same selection + enlarge + place on a new layer + mask background + crop transparent
  2. But then crop only Up and Bottom, not Left and Right
  3. Then crop with crop tool set up to 2:3 and that's it
  4. Delete layer and save to a new destination folder

Easy to record, easy to batch process the 1000 pics

didiermazier
Community Expert
Community Expert
March 8, 2020

All provided scripts are excellent. I would personnaly use a simpler script (no coding) doing the following :

  1. Select a subject
  2. Enlarge the selection about 300 px (depend on the image) just to get further margins
  3. Duplicate the selection on a new layer (command+J)
  4. Mask the background
  5. Crop the image to transparent pixels
  6. Delete layer

Done

Stephen Marsh
Community Expert
Community Expert
March 8, 2020

didiermazier what am I missing in your post? How does this preserve the 2:3 aspect ratio in the cropped image, which is a key requirement of the OP? 

 

"Script
Detect Model's height and crop leaving a few pixels above the head and bellow the feet.
Model should be centered on the image.
Keep aspect ratio 2:3."

 

There is a reason for the scripting leveraged by the action in my previous post, my approach results in a 2:3 aspect ratio crop, with the model centred and a small amount of space above/below the subject. Just as the original posters images show:

 

 

 

 

didiermazier
Community Expert
Community Expert
March 8, 2020

My bad!

In this case there is a much simpler way :

Use content aware scale (alt+shift+ctrl+c) and you are good to go

Stephen Marsh
Community Expert
Community Expert
March 8, 2020

I have adapted the action/helper scripts from the previously linked topic thread to crop to 2:3 aspect ratio. The action relies on three key functions:

 

1) Select menu > Subject

2) Helper script: Add Guides to Selection Bounds

3) Helper script: FitImageToGuides

 

 

The action and helper scripts are all available for download here:

 

CropModelShots2to3.zip

 

Downloading and Installing Adobe Scripts

 

Mac OS Example:

/Applications/Adobe Photoshop CC 2018/Presets/Scripts

 

Win OS Example:

C:\Program Files\Adobe\Adobe Photoshop CC 2018\Presets\Scripts

 

Further information at the Adobe site:
Scripting

 

NOTE: If running, Adobe Photoshop must be quit and restarted for newly added scripts to become accessible.

Stephen Marsh
Community Expert
Community Expert
March 2, 2020

The methods in the following topic thread can be easily modified for your task, it is almost the same:

 

Script help: Crop based on select subject