Skip to main content
Inspiring
April 20, 2021
Answered

batch crop from face detection?

  • April 20, 2021
  • 5 replies
  • 13396 views

Hi, say i have a bunch of portraits from unsplash and want to use photoshop to crop them using automate - square ratio and with face detection - so all the faces essientially line up within the square box/rule of thirds. 

This topic has been closed for replies.
Correct answer michael_godfrey

If you're using a version of Photoshop with face manipulation in the Liquify plugin, this isn't too difficult to do with actions.  After seeing this post I figured I'd see if I could figure out a non-script plugin for out of the box Photoshop.  It wasn't too hard.  Basically the action does this:

1. Duplicate the image.

2. Run liquify on the image to edit the scale of elements of the face.

3. Use difference blending to identify changes to the face elements and isolate.

4. Scale that isolation up to give you a desired outside edge of your crop.

5. Use cropping methods to size properly and crop to a square.

6. Delete all but the background.

 

The scaling of the isolated face elements defines how tight you crop on the faces, so changing Transform Current Layer with aspect ratio locked will allow for that to be changed. 

 

This action is set to scale to 200x200 pixels using landscape or portrait detection.  Changing both of those Image Size settings will allow for different thumbs.

 

Add your prefered saving method and run it with a batch.  It seems to work great for me.  

 

CropOnFace.zip 

 

As a note, it is a little limited.  I've only run it on images with single individuals.  It will only work on the first face Liquify selects.  You can probably use Liquify's multiple face selection to set up different versions of the action for 2, 3, 4, etc..., but they would most likely error when the count is more than the available faces.

5 replies

michael_godfreyCorrect answer
New Participant
October 3, 2022

If you're using a version of Photoshop with face manipulation in the Liquify plugin, this isn't too difficult to do with actions.  After seeing this post I figured I'd see if I could figure out a non-script plugin for out of the box Photoshop.  It wasn't too hard.  Basically the action does this:

1. Duplicate the image.

2. Run liquify on the image to edit the scale of elements of the face.

3. Use difference blending to identify changes to the face elements and isolate.

4. Scale that isolation up to give you a desired outside edge of your crop.

5. Use cropping methods to size properly and crop to a square.

6. Delete all but the background.

 

The scaling of the isolated face elements defines how tight you crop on the faces, so changing Transform Current Layer with aspect ratio locked will allow for that to be changed. 

 

This action is set to scale to 200x200 pixels using landscape or portrait detection.  Changing both of those Image Size settings will allow for different thumbs.

 

Add your prefered saving method and run it with a batch.  It seems to work great for me.  

 

CropOnFace.zip 

 

As a note, it is a little limited.  I've only run it on images with single individuals.  It will only work on the first face Liquify selects.  You can probably use Liquify's multiple face selection to set up different versions of the action for 2, 3, 4, etc..., but they would most likely error when the count is more than the available faces.

New Participant
February 14, 2023

Hey Michael,

Thanks for posting this. I can't access the link, so I've tried to walk through the steps and I'm getting stuck on the isolation in step 3. By isloate, you mean select right? When I try to select, it's selecting elements from the original image. I'm not sure how to get it to select just the difference.

 

  

Stephen Marsh
Community Expert
June 16, 2021

A related topic here: Crop/trim image automation 3:4

Stephen Marsh
Community Expert
April 20, 2021

Your right. Photoshop doesn't have a dedicated tool or many facial recognition features. The only one I can think of is liquify. I just experimented with the liquify filter using facial aware settings to isolate and bloat the face. I then made a difference mask between the liquify processed image and the original image. A few more steps and I had a selection around the face and then a crop. This could be batched with an action. I was pleasantly surprised with this proof of concept, however it would need more work and testing. Other steps would also be required.

 

Some catalogue software may write metadata to the file defining facial tags for names, which could possibly be another option if the metadata bounding area could be used.

 

None of this is out of the box or easy I'm afraid.

Inspiring
April 20, 2021

I don't think theres a way to do it, I bet no one on here can tell me how to do this.

 

Inspiring
April 20, 2021

I mean I have seen some third party apps like portraitcrop, but its 240 dollars, yikes,  it would be nice if there was a way to crop faces natively in photoshop. I just got the code version of autocrop to work using terminal, and its decent and free, but I'd like more control with photoshop. I am suprised this isn't a default feature considering how expensive it is and that PS is 'the premiere photo editor'. It should be easier by now considering there have been things that can do this on github for years now... I don't think Photoshop can detect a face and autocrop it to specified set of values like some of these free github croppers can do, but I would be happy if someone can prove me wrong.

JJMack
Community Expert
April 20, 2021

So you can not do what you want to do because you do not have the programming skills and you do not want to shell out 240 for an Application someone labored design and code. 

 

You want a Photoshop add on to automate your portrait cropping.

 

While there are Photoshop features that detects faces in image and you can work on face features interactivity. An image may have many faces and you interactivity edit one face are a time. All face images are not Portrait images. Photoshop face detection is also not 100% successful, The features that do detect faces  do not  provide a way for the users to set an active selection for the faces detected and Photoshop Face detection detects facial features to work on  so even of you could make a selection from Photoshop face detection the selection would not include the person's hair, hat  or hairless head shape.   Photoshop Face detection would not be useful in your automated Photoshop process.

 

Your Photoshop add on would need to detect whole heads and hat or head.  If you know your images are portraits you may be able to start your Photoshop's  Scripts processing with  Photoshop select subject. Then  get the selection bounds then calculate a crop that is a bit wider then the selections bound and the height be something like top 3/4 of select subjects height selection height bounds.   You could test a few of your portrait images manually  using select subject  to see if  such a process would yield the results you want before coding the script.

JJMack
Mylenium
Brainiac
April 20, 2021

And what is your actual question? Have you even tried yet?

 

Mylenium

Inspiring
April 20, 2021

Didn't let me fix my typos, the questions is how to batch crop using face detection in photoshop, and is it possible?