Crop/trim image automation 3:4

Community Beginner ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

Cropping a lot of images one by one. Need your help to speed up the process.

Final image should be :

Aspect ratio 3:4.

Keep the background color.(might change...but mostly in the 240-255 values)

Center the subject.

Crop above the nose.

Any help is appreciated !

TOPICS
Actions and scripting

Views

4.5K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jun 16, 2021 Jun 16, 2021
I didn't care about compatibility and I'm assuming you are using the latest versions of photoshopIf necessaryyou can refuse to use the Select Subject function and take the coordinates of the nose as the center of the selection

 

#target photoshop

var lr = new AM('layer'),
    doc = new AM('document');

lr.copyCurentToLayer()
lr.liquify()
lr.fade('difference')
lr.levels([0, 0.2, 8])
lr.makeSelectionFromChannel('blue')

if (doc.hasProperty('selection')) {
    var selectionBounds = doc.descToO
...

Likes

Translate

Translate
LEGEND ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied

        var mesh= String.fromCharCode(0, 0, 0, 16, 0, 0, 0, 1, 0, 0, 0, 0, 0, 8, 102, 97, 99, 101, 77, 101, 115, 104, 0, 0, 0, 3, 0, 0, 0, 21, 102, 97, 99, 101, 68, 101, 115, 99, 114, 105, 112, 116, 111, 114, 86, 101, 114, 115, 105, 111, 110, 108, 111, 110, 103, 0, 0, 0, 2, 0, 0, 0, 15, 102, 97, 99, 101, 77, 101, 115, 104, 86, 101, 114, 115, 105, 111, 110, 108, 111, 110, 103, 0, 0, 0, 2, 0, 0, 0, 12, 102, 97, 99, 101, 73, 110, 102, 111, 76, 105, 115, 116, 86, 108, 76, 115, 0, 0, 0, 1, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 8, 102, 97, 99, 101, 73, 110, 102, 111, 0, 0, 0, 3, 0, 0, 0, 10, 102, 97, 99, 101, 67, 101, 110, 116, 101, 114, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 110, 117, 108, 108, 0, 0, 0, 2, 0, 0, 0, 0, 88, 32, 32, 32, 100, 111, 117, 98, 63, 222, 208, 81, 126, 75, 23, 229, 0, 0, 0, 0, 89, 32, 32, 32, 100, 111, 117, 98, 63, 214, 68, 141, 240, 18, 52, 86, 0, 0, 0, 13, 102, 101, 97, 116, 117, 114, 101, 86, 97, 108, 117, 101, 115, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 13, 102, 101, 97, 116, 117, 114, 101, 86, 97, 108, 117, 101, 115, 0, 0, 0, 5, 0, 0, 0, 5, 115, 109, 105, 108, 101, 100, 111, 117, 98, 63, 204, 40, 245, 192, 0, 0, 0, 0, 0, 0, 8, 117, 112, 112, 101, 114, 76, 105, 112, 100, 111, 117, 98, 191, 202, 225, 71, 160, 0, 0, 0, 0, 0, 0, 8, 108, 111, 119, 101, 114, 76, 105, 112, 100, 111, 117, 98, 63, 202, 225, 71, 160, 0, 0, 0, 0, 0, 0, 10, 109, 111, 117, 116, 104, 87, 105, 100, 116, 104, 100, 111, 117, 98, 63, 196, 122, 225, 64, 0, 0, 0, 0, 0, 0, 11, 109, 111, 117, 116, 104, 72, 101, 105, 103, 104, 116, 100, 111, 117, 98, 63, 204, 40, 245, 192, 0, 0, 0, 0, 0, 0, 20, 102, 101, 97, 116, 117, 114, 101, 68, 105, 115, 112, 108, 97, 99, 101, 109, 101, 110, 116, 115, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 20, 102, 101, 97, 116, 117, 114, 101, 68, 105, 115, 112, 108, 97, 99, 101, 109, 101, 110, 116, 115, 0, 0, 0, 0);

That detected this

image.png

 

		var mouth = String.fromCharCode(0, 0, 0, 16, 0, 0, 0, 1, 0, 0, 0, 0, 0, 8, 102, 97, 99, 101, 77, 101, 115, 104, 0, 0, 0, 3, 0, 0, 0, 21, 102, 97, 99, 101, 68, 101, 115, 99, 114, 105, 112, 116, 111, 114, 86, 101, 114, 115, 105, 111, 110, 108, 111, 110, 103, 0, 0, 0, 2, 0, 0, 0, 15, 102, 97, 99, 101, 77, 101, 115, 104, 86, 101, 114, 115, 105, 111, 110, 108, 111, 110, 103, 0, 0, 0, 2, 0, 0, 0, 12, 102, 97, 99, 101, 73, 110, 102, 111, 76, 105, 115, 116, 86, 108, 76, 115, 0, 0, 0, 1, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 8, 102, 97, 99, 101, 73, 110, 102, 111, 0, 0, 0, 3, 0, 0, 0, 10, 102, 97, 99, 101, 67, 101, 110, 116, 101, 114, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 110, 117, 108, 108, 0, 0, 0, 2, 0, 0, 0, 0, 88, 32, 32, 32, 100, 111, 117, 98, 63, 223, 253, 143, 32, 0, 0, 0, 0, 0, 0, 0, 89, 32, 32, 32, 100, 111, 117, 98, 63, 195, 208, 61, 128, 0, 0, 0, 0, 0, 0, 13, 102, 101, 97, 116, 117, 114, 101, 86, 97, 108, 117, 101, 115, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 13, 102, 101, 97, 116, 117, 114, 101, 86, 97, 108, 117, 101, 115, 0, 0, 0, 1, 0, 0, 0, 5, 115, 109, 105, 108, 101, 100, 111, 117, 98, 63, 169, 153, 153, 160, 0, 0, 0, 0, 0, 0, 20, 102, 101, 97, 116, 117, 114, 101, 68, 105, 115, 112, 108, 97, 99, 101, 109, 101, 110, 116, 115, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 20, 102, 101, 97, 116, 117, 114, 101, 68, 105, 115, 112, 108, 97, 99, 101, 109, 101, 110, 116, 115, 0, 0, 0, 0);

detected this:

image.png

I think Images Size and the Scale of object in the image  Have a big impact ot the sliders effects in Liquify

JJMack

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied

@JJMack  Both Code are used But Mouth is not detected perfectly !

Try this image !

sdsad.JPG

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied

The mesh I posted  selected most of the lips. I create mesh setting the smile slider  + some small number, The image you posted is quite small like 500x700px when cropped to the image the selection the mesh made looks like this:

image.png

image.png

 

 

JJMack

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

I saw this pic But Lips can't perfect selection of width and height @JJMack 

@jazz-y Can you make a Liquify For Mouth Detection , I have tired too !

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

I still travel and will not be at the computer soon.

Check the level parameters that are applied to the image after the fade is applied in the difference mode. in this thread I have used options that are more suitable for selecting objects with a large area. follow the script step by step and check how well they show the lips. for highlighting small objects I usually use equalize instead of levels.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

I am surprised that these saved meshes work as well as the do,  Images have different Sizes (Number of Pixels), different Aspect Ratios (Canvas Shape) and object  scale for example Heads ( Portrait,  Half Body, Full bode, Groups)   The mesh require for each will different.  I'm sure Liquify will user its AI to detect heads and then have a meshes  for each face that cams be saved, that may work well similar  Images.

 

Here I saved a mesh  I created toe detect a nose on a square  2K  x 2K 3/4+ body  shot posted in a thread. So  a 4MP image. Here  I show what it select on the original square  3/4 body shot 4MP image then a 1MP portrait,  4mp,  image,  an 8mp Imags,  and a 50MP  image. I have also seen scriptner save different amount a days for mashes.  When I use Jazz-y converter I have to strip most of the beginning mesh.  Sometime Script listen records no mesh seem to leave it undefined for liquify to figure out.  I do not understand how Liquify works here.

Capture.jpg

 

JJMack

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

On you small test image this mesh did well.  It does not work well on large images,

        var test = String.fromCharCode(0, 0, 0, 16, 0, 0, 0, 1, 0, 0, 0, 0, 0, 8, 102, 97, 99, 101, 77, 101, 115, 104, 0, 0, 0, 3, 0, 0, 0, 21, 102, 97, 99, 101, 68, 101, 115, 99, 114, 105, 112, 116, 111, 114, 86, 101, 114, 115, 105, 111, 110, 108, 111, 110, 103, 0, 0, 0, 2, 0, 0, 0, 15, 102, 97, 99, 101, 77, 101, 115, 104, 86, 101, 114, 115, 105, 111, 110, 108, 111, 110, 103, 0, 0, 0, 2, 0, 0, 0, 12, 102, 97, 99, 101, 73, 110, 102, 111, 76, 105, 115, 116, 86, 108, 76, 115, 0, 0, 0, 1, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 8, 102, 97, 99, 101, 73, 110, 102, 111, 0, 0, 0, 3, 0, 0, 0, 10, 102, 97, 99, 101, 67, 101, 110, 116, 101, 114, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 110, 117, 108, 108, 0, 0, 0, 2, 0, 0, 0, 0, 88, 32, 32, 32, 100, 111, 117, 98, 63, 227, 246, 149, 248, 235, 241, 216, 0, 0, 0, 0, 89, 32, 32, 32, 100, 111, 117, 98, 63, 224, 149, 72, 155, 229, 78, 55, 0, 0, 0, 13, 102, 101, 97, 116, 117, 114, 101, 86, 97, 108, 117, 101, 115, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 13, 102, 101, 97, 116, 117, 114, 101, 86, 97, 108, 117, 101, 115, 0, 0, 0, 3, 0, 0, 0, 8, 117, 112, 112, 101, 114, 76, 105, 112, 100, 111, 117, 98, 63, 158, 184, 81, 224, 0, 0, 0, 0, 0, 0, 8, 108, 111, 119, 101, 114, 76, 105, 112, 100, 111, 117, 98, 191, 132, 122, 225, 64, 0, 0, 0, 0, 0, 0, 10, 109, 111, 117, 116, 104, 87, 105, 100, 116, 104, 100, 111, 117, 98, 63, 169, 153, 153, 160, 0, 0, 0, 0, 0, 0, 20, 102, 101, 97, 116, 117, 114, 101, 68, 105, 115, 112, 108, 97, 99, 101, 109, 101, 110, 116, 115, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 20, 102, 101, 97, 116, 117, 114, 101, 68, 105, 115, 112, 108, 97, 99, 101, 109, 101, 110, 116, 115, 0, 0, 0, 0);

image.png

JJMack

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

Small Image and Big Image will same pixel of mouth detection, then it's perfect @JJMack 

I have requested @jazz-y  For Mouth Detection Of Perfect PiXel, Wait @JJMack  

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

I do not believe it will be perfect with vastly different size images. The image you posted is a webs size image 336K pixels 472 px by 712 px.  Here I scaled it up 10 X  34 MP  4720 Px be 7120 Px   about  a 16" by 20" 300ppi print image and I use the same mesh. neither was perfect.  Too little selected on the web image too much selected on the Print Image.  May be perfect on some in between size image.  I have know idea how Adobe Face detection works and the seem to be more than one detection methods used by Adobe. Select Color range has Face detection Liquify has face detection, Neural Filters have face detection and these seem to work differently from what I see selected. Some faces are enevn missed.

image.png

 

Faces vary and perspective proportions vary etc.

 

 

JJMack

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

@JJMack  Can you send me perfect code of Mouth Detection ?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 20, 2021 Jul 20, 2021

Copy link to clipboard

Copied

I do not have that mesh any more. It was only I test one I later pasted over it.  Use  Jazz-y converter and create your own.  It may be perfect for a few images it still depends on how Liquify detect faces in images and faces vary in many aspects, Liquify  also fails to detect some faces in Image.  You should not expect perfect selection.   I tend to try to get small selections I then add some area to in scripting code 

JJMack

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

 

var mesh = String.fromCharCode(0, 0, 0, 16, 0, 0, 0, 1, 0, 0, 0, 0, 0, 8, 102, 97, 99, 101, 77, 101, 115, 104, 0, 0, 0, 3, 0, 0, 0, 21, 102, 97, 99, 101, 68, 101, 115, 99, 114, 105, 112, 116, 111, 114, 86, 101, 114, 115, 105, 111, 110, 108, 111, 110, 103, 0, 0, 0, 2, 0, 0, 0, 15, 102, 97, 99, 101, 77, 101, 115, 104, 86, 101, 114, 115, 105, 111, 110, 108, 111, 110, 103, 0, 0, 0, 2, 0, 0, 0, 12, 102, 97, 99, 101, 73, 110, 102, 111, 76, 105, 115, 116, 86, 108, 76, 115, 0, 0, 0, 1, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 8, 102, 97, 99, 101, 73, 110, 102, 111, 0, 0, 0, 3, 0, 0, 0, 10, 102, 97, 99, 101, 67, 101, 110, 116, 101, 114, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 110, 117, 108, 108, 0, 0, 0, 2, 0, 0, 0, 0, 88, 32, 32, 32, 100, 111, 117, 98, 63, 222, 74, 3, 96, 0, 0, 0, 0, 0, 0, 0, 89, 32, 32, 32, 100, 111, 117, 98, 63, 212, 76, 98, 42, 170, 170, 171, 0, 0, 0, 13, 102, 101, 97, 116, 117, 114, 101, 86, 97, 108, 117, 101, 115, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 13, 102, 101, 97, 116, 117, 114, 101, 86, 97, 108, 117, 101, 115, 0, 0, 0, 1, 0, 0, 0, 5, 115, 109, 105, 108, 101, 100, 111, 117, 98, 191, 217, 153, 153, 160, 0, 0, 0, 0, 0, 0, 20, 102, 101, 97, 116, 117, 114, 101, 68, 105, 115, 112, 108, 97, 99, 101, 109, 101, 110, 116, 115, 79, 98, 106, 99, 0, 0, 0, 1, 0, 0, 0, 0, 0, 20, 102, 101, 97, 116, 117, 114, 101, 68, 105, 115, 112, 108, 97, 99, 101, 109, 101, 110, 116, 115, 0, 0, 0, 0);

 

Liquify only allows you to roughly estimate the area of the face element. This is due to the fact that even the smallest correction can introduce a large amount of noise into the nearest pixels.

2021-07-23_10-05-45.png

Filtering out this noise and leaving only the necessary pixels is a rather creative task that needs to be solved and tested on a large array of images.

In this case, I slightly changed the levels parameters.

2021-07-23_10-16-49.png

 

 

lr.levels([10, 0.2, 15])

 

However, this does not mean that this method will work for all images. Perhaps a gaussian blur should be added before levels to blend the pixels of minimal intensity with the background. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

Why make such big mouth changes? Try with MouthWidth = 1. Then, through Calculations, create a selection from the Gray Difference. Apply Smooth 5, and... voila, a border without any Levels. As a last resort, you can use Threshold instead of Levels.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

You probably refer to script so in your hint there are missing some steps. I understand you duplicate the layer, make liquify for mouth width equal to 1, then calculations (source one: channel: Gray, blending: difference)? What's then to apply smooth to unexisting selection yet?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

@r-bin, small distortion values on small images can make the difference indistinguishable from noise. Larger values ​​give more noise, but at the same time higher brightness values in places of maximum difference. Since liqufy is essentially a black box, the result of which we can evaluate only indirectly, we always need to look for a balance of settings to solve a specific task.

 

Also, on complex layouts with a lot of design elements, for no apparent reason, applying difference after liquify sometimes produces large areas of noise in areas not related to the subject's face. That is, one way or another, it is better to provide for ways to remove it.

 

I prefer gaussian blur as it is a fairly simple function that produces results almost instantly on most computers.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

I use smooth that 'kills' unwanted 'single' pixels selection, but it works slow with big value.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 19, 2021 Jul 19, 2021

Copy link to clipboard

Copied

Jazzy

it works perfectly

thanks for your great contribution.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

Loll, he got linked to the topic where it is 🙂

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

Can this be done using pixel ratios instead of 3:4 ?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

I have used lighroom for this and it works great - especially when there are alot of images

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 17, 2021 Jun 17, 2021

Copy link to clipboard

Copied

I confirm, once I installed it and it detects faces really good, at the time of working, so in backround.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 23, 2021 Jul 23, 2021

Copy link to clipboard

Copied

some have noticed that the selection changes based on the dpi of the photo.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 30, 2021 Jul 30, 2021

Copy link to clipboard

Copied

@Adrian5FF9  (original topic poster)

 MXKS

 

Please mark one or multiple answers as correct so that others with the same/similar question know that an answer was found.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 30, 2022 Jun 30, 2022

Copy link to clipboard

Copied

LATEST

Can someone help me, I have never made a script before and from the same photoshoot I need to crop to different vendors at pixel ratios all 300dpi. Some vendors have the crop right under the eyes like the image posted here, others have crops right below the nose, above the lips and then also right below the lip.

 

i know for certian crops, the backgounds would need to be expanded, so i applied the RGB values.

 

Macy's Full body - 3894px x 4755px crop under eyes Background RGB 245

Macy's Half Body - 3894px x 4755px Crop mid thigh Background RGB 245

Nordstrom  -  2640px x 4048px crop right under nose Background RGB 255

Walmart - 1500px x 2000px crop right below the lip Background RGB 255

Saks Full body - 3000px x 3000px crop under eyes Background RGB 255

Saks Half Body - 3000px x 3000px Crop mid thigh Background RGB255

 

Thank you in advance! 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines