Detecting guides in photoshop script

Posted on 2009-04-16
Last Modified: 2012-05-06
I need to automate the processing of about 2500 product images and I think scripting Photoshop is the best way to do it.

For each image I need to:
1) Straighten it
2) Crop it leaving a set amount of space around the bounding box of the product
3) Fade from the edge of the product's bounding box to the edge of the image, going from the current background colour (almost white) to white

I am hoping to do this as follows:

1) A human opens each image, straightens it and defines the bounding box of the product using guides (I think that's what they are called - they blue lines you drag in off the side rules using the move tool) and saves the image.

2) A script opens up each image and, using the canvas size and the size and location of the bounding box, crops and adds the fades to the image.

This should be *much*faster than getting someone to do it all by hand, and also gives me the option to re-run the batch processing later if I want to change one of the parameters.

Is this a workable solution?  Can I detect the guides in a Photoshop script?  If not, can you think of an alternative method of recording the specification of the bounding box of each product so that a script can access it?

I considered creating another layer and drawing a rectangle over the bounding box of the product for example, and then getting the script to detect the edges of the rectangle...

I dont have any experience scripting Photoshop, I just want to make sure that what I am trying to do is possible before starting out!

We sell Single Malt Scotch Whisky (all the images are whisky) so if anyone feels like writing the script for me we might be able to come to an arrangement involving a few bottles of the good stuff ;-)



Question by:jtp101
    LVL 12

    Accepted Solution

    use a channels instead? have the user make a rectangular selection and then save the selection. then after opening the image in the script, load the selection, get it's bounds and go from there.

    Author Comment

    Brilliant  that sounds like it would work!

    Do you know anyone who would be able / interested in writing the script to handle the images once the selection has been saved?  I can pay in Whisky or, if needs be, cold hard cash.

    Out of interest, do you know that detecting the guides wouldnt work or did the alpha channel method just seem like a nicer way to do it?
    LVL 12

    Expert Comment

    I don't believe you have access to the guides via scripting. At least for JavaScript that is.

    I don't have time at the moment to write the script, even though it isn't that difficult. So if someone else wants to jump in, please do. If no one else can, I'll try to see if I can get to it later (tonight, maybe?)


    Author Comment

    If you could put a script together or recomend someone who could I would be very grateful.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    HOW TO CREATE A WEB 2.0 IMAGE WITH A REFLECTION I would like to start by saying I know Web 2.0 isn't a style. It is actually the practice of information sharing or  collaboration on the Web. It is also associated with the technology that is used …
    This article will show, step by step, how to integrate R code into a R Sweave document
    In this tutorial viewers will learn how to select a color range in Photoshop and how to easily apply them to multiple projects. Open an image for editing in Photoshop: Open the select Color Range Selection tool by going to Select > Color Range: Sele…
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now