• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
4

Auto detect square shape and perspective warp

Participant ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

I am here desiring to tap into the brilliant minds who are aware of all the new and cool possibilities of AI, Photoshop, and scripting. 🤓

 

I don't know if this is possible, but those who do not ask for help will never learn something new, right? So here goes 😄

 

Situation

Thousands of photos contain the same wooden box and an object inside and outside, but they are not all taken from the same angle.

 

Aim 1

- Autodetect the edges of the wooden box

- Perspective Warp to make it a straight and square box

 

Aim 2

- Place these photos into a template as smart layers

- Resize the photo to make the wooden box 400x400px

- Distribute layers on a grid

 

The end result would be a collage of a group of my photos in a grid of wooden boxes of the same size and shape. Without me spending hours and hours doing this all manually 🤯

 

Thanks in advance for your time!

TOPICS
Actions and scripting , macOS

Views

542

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 2 Correct answers

Community Expert , Mar 14, 2024 Mar 14, 2024

This would run the Action »Action 22« from »Set 1« if the selected Layer is a Smart Object, then selects the next Layer below. 

You would need to amend the names and the Action itself. 

 

// 2024, use it at your own risk;
if (app.documents.length > 0) {
var check = isSmartObject();
while (check == true) {
app.doAction("Action 22", "Set 1")
var desc6 = new ActionDescriptor();
var ref4 = new ActionReference();
ref4.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( 
...

Votes

Translate

Translate
Community Expert , Mar 14, 2024 Mar 14, 2024

I edited the code, please try that. (edit: Sorry, I hadn’t thought through the process.)

The Action itself should only open, edit, save, close the Smart Object, the rest should be handled with a while-clause and stop once it hits a non-Smart Object. 

ifSmartObjectRunActionScr.gif

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 12, 2024 Mar 12, 2024

Copy link to clipboard

Copied

Please post a few samples (as they are and the intended result). 

 

I expect semi-automation is possbile (creating a four point path manually and running the rest automatically) but I doubt full automation in Photoshop is plausible at current. 

Maybe you should search beyond Photoshop, though. 

Votes

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 ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

Thanks for responding so quickly! Unfortunately, I can not share the images as there are also people on there, and the regulations and privacy prevent me from showing them.

 

Yeah, I also doubt my Aim 1 exists, but I figured I would ask. Aim 2 I already have kind of roughly automated with actions, etc, but it needs tweaking, which I wanted to do in the case Aim 1 was going to change the setup.

 

The puzzle is the existing action for me to solve/ I want to solve, which is that a set of steps are repeated repeatedly, depending on the number of photos. Currently I am adding the steps 50 times to make sure there are enough. Looking for a 1 set that I can rerun automatically and based on a condition (no more layers) it will stop. Any ideas for that?

Votes

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 Expert ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

A Script could easily iterate through the Layers in a file or the open files or offer a file selection dialog … but I it seems pointless trying to assist without meaningful information. 

Please post requested sample images or layered image (feel free to black out sensitive areas, so long as the »square« remains recognizable) already. 

Votes

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 ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

I understand. I'm sorry for trying to ask without doing some legwork myself and creating hypothetical examples. Do know that I appreciate your fast replies and feedback. Thanks!

 

I will share examples and more detailed information as soon as I can.

Votes

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 Expert ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

A while back I posted a Script that can be used to transform a Smart Object with a four-point-vector-mask so that it results in a rectangular shape. 

Votes

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 ,
Mar 13, 2024 Mar 13, 2024

Copy link to clipboard

Copied

Interesting, thanks for sharing!! I will read it later today

 

Currently trying to find a fix for the repeating of an action. Photoshop keeps showing 

Could not complete the Play command because the action is already playing.

 

I am not a scripter; I can read scripts and I am just very obsessed with fixing things with search, try, fail, search again, fail, ask, try something else, etc. But coming up short on able to fix it.

 

Basically after the first smart layer is warped correctly, it should restart the same action, but it gave the error. I tried to make a 2nd action, hoping it would close the 1st and, at the end of the 2nd, go back to the first. Creating a loop until the last layer and there is no pixel layer found, making the action go to the resize script.

 

See below the screenshot of the action and steps. Any idea's 🙏🏻

 

Screenshot 2024-03-13 at 14.13.19.png

Votes

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 Expert ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

This would run the Action »Action 22« from »Set 1« if the selected Layer is a Smart Object, then selects the next Layer below. 

You would need to amend the names and the Action itself. 

 

// 2024, use it at your own risk;
if (app.documents.length > 0) {
var check = isSmartObject();
while (check == true) {
app.doAction("Action 22", "Set 1")
var desc6 = new ActionDescriptor();
var ref4 = new ActionReference();
ref4.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Bckw" ) );
desc6.putReference( charIDToTypeID( "null" ), ref4 );
desc6.putBoolean( charIDToTypeID( "MkVs" ), false );
executeAction( charIDToTypeID( "slct" ), desc6, DialogModes.NO );
check = isSmartObject();
};
};
////// is smart object //////
function isSmartObject (theId) {
var ref = new ActionReference();
ref.putProperty (stringIDToTypeID ("property"), stringIDToTypeID ("smartObject"));
if (theId) {ref.putIdentifier( charIDToTypeID("Lyr "), theId )}
else {ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ))};
var layerDesc = executeActionGet(ref);
var isSmartObject = layerDesc.hasKey(stringIDToTypeID("smartObject"));
return isSmartObject
};

 

 

Votes

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 ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

The script works perfectly! However, I am unable to get it to work as a loop without the error message 😕 

In light of your feedback regarding the lack of examples etc, I have created a new post (to avoid the Ai request confusing other future people with the desire to loop an action) and added an example set, the action and scripts in there. See This post

Votes

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 Expert ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

I edited the code, please try that. (edit: Sorry, I hadn’t thought through the process.)

The Action itself should only open, edit, save, close the Smart Object, the rest should be handled with a while-clause and stop once it hits a non-Smart Object. 

ifSmartObjectRunActionScr.gif

Votes

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 ,
Mar 14, 2024 Mar 14, 2024

Copy link to clipboard

Copied

LATEST

🙏🏻 YES! It works!! As you can see in the other post, I want to automate more steps, but this is already a tremendously helpful step! Thanks!!

Votes

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