Skip to main content
AG_Ps_100
Inspiring
May 23, 2018
Question

Script to Straighten-and-crop to shapes

  • May 23, 2018
  • 1 reply
  • 1312 views

Hello everyone,

I edit carpet NEF files of carpets (adjust to the correct colors, remove the background, straighten the carpet, and add watermark)

I want to better automate my straightening of the carpet. I use Camera Raw's upright option but the features there work just sometimes:

since i get 7-9 pictures of each carpet from a photographer not every carpet is the same, let's say that angle from above of the carpet as a rectangle, i want to automate probably by a script the process of Straightening-and-cropping.

I saw like 5 scripts to auto crop but none of them served me well.

I would probably need a script that works inside photoshop (work on opened tabs and not on a folder) via a script or action. sometimes straightening the carpet requires Free Transform > Distort and sometimes Free Transform > Warp and sometimes even both.

example to distort:

Before:

take the top right corner and move it a bit right, and take the bottom right and move it a bit left:

After:

Example to Wrap Tool:

i wish i could define a shape like rectangle in this situation that the carpet will try to mimic and have the same structure, using both wrap and distort

does anyone can think of an idea where i can start?

This topic has been closed for replies.

1 reply

JJMack
Community Expert
Community Expert
May 23, 2018

If you know nothing about scripting Photoshop heir a programmer that does. Also work with the photographer to capture image that will work well with your automated process.

JJMack
AG_Ps_100
AG_Ps_100Author
Inspiring
May 25, 2018

i'm actually pretty decent at scripting, just stuck, i improved my process and got to this point where all that is left to do is the auto wrap around the canvas (rather than around a shape) which is an easier task!

the canvas is trimmed.

so the layer edges is exactly on the canvas as can be seen in the picture.

my problem is that the picture inside the layer is not straight

JJMack
Community Expert
Community Expert
May 25, 2018

The problem is your carpet image is distorted.  The rug has a perspective distortion or is not flat with straight sides.  It can not be straightened.  The image rug's image is not a rectangle.  If you could figure out the four corner x,y point or near the four corners perhaps you could script a perspective crop to straighten it remove the perspective distortion.

JJMack