Time to be with your loved ones

Time to be with loved ones

by sat

submit your photo


Hall of Fame
View past winners from this year

Please participate in Meta
and help us grow.

Take the 2-minute tour ×
Photography Stack Exchange is a question and answer site for professional, enthusiast and amateur photographers. It's 100% free, no registration required.

I have a repetitive process I would very much like to automate in Photoshop, but I am afraid that it is just ever so slightly too complicated.

I have ~1000 pictures of a sunset, each taken a couple of seconds apart (think time lapse).

I want to take 4px wide vertical strips from each photo, and then paste them next to each other, so that as you move left to right across the image, the sunset gets further along.

So the first 4 pixels of my final image are from picture 1, the second 4 pixels from picture 2, etc.

I can't figure out how to create an action that is different every time, eg. select a 4px wide strip at registrations increasing by 4 pixels each time.

Any ideas?

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

You're going to need to get into loops and variables within the script to do it. Assuming the files are named sequentially as most sane cameras would generate them, then it would look roughly like this at the 50,000' elevation:

//control variable, counts which photo you're on
var lcv = 0;

//how many photos are there?
var numPhotos = 1000;

//used to track the name of the file in the loop
var filename;
//used to track the shape to cut in the loop
var shapeRef;
//used to track the left and right edges of the slice
var leftEdge;
var rightEdge;

//main processing loop
for (lcv = 0; lcv < numPhotos; lcv++ ) {
    // process one image.
    filename = 'img_'+(lcv + 1234)+'.jpg';

    //open the file here... get it ready to cut from
    ...

    //create the selection box here, we'll use the LCV to control how far over we move
    leftEdge = lcv * sliceWidth;
    rightEdge = leftEdge + sliceWidth;
    shapeRef = [ [leftEdge, 0], //upper left
                 [rightEdge, 0], //upper right
                 [rightEdge, 3400], //lower right
                 [leftEdge, 3400] ]; //lower left

    // use the above shapeRef to first cut from the above opened file, then paste it into your master file.

    // close the file you opened above so we can move on to the next file

}

I've made some assumptions above:

  1. you're coding in JS
  2. first image is number 1234, and they go in order, with names like "img_1234.jpg"
  3. the file is 3400 pixels tall.
  4. you already know how to open the image, cut the slice out and paste it into another image. :)

If the first couple aren't legit assumptions, adjust the code as needed. ;)

If you need more help with the syntax of using variables, two references come to mind:

  1. Adobe's Excellent intro scripting guides
  2. W3 school's JS resources or the Mozilla Developers Center's JS section
share|improve this answer
    
In addition to your references, here's a w3 schools reading companion I recently stumbled upon: w3fools.com –  koiyu Jan 19 '11 at 9:36
    
wow, thanks for that pointer koiyu! –  cabbey Jan 20 '11 at 5:57
    
Kudos for providing a code outline in addition to answering the question! –  Matt Grum Jan 20 '11 at 17:37
add comment

Just for those interested here is the final script:

-- Script to merge 1043 images into a single image by taking slices and
-- reassembling them

-- Target Adobe Photoshop
tell application "Adobe Photoshop CS5"
    activate

    -- Create the ultimate document
    set uDocRef to make new document with properties {width:2848 as pixels, height:4288 as pixels}

    -- First image number of the series
    set firstNum to 868
    set lastNum to 1580
    set leftEdge to 0

    -- Step through each picture
    repeat with currentNum from firstNum to lastNum
        -- Open the image
        if currentNum is less than 1000 then
            set tCurrentNum to "0" & currentNum
        else
            set tCurrentNum to currentNum
        end if

        set filePath to ".../DSC_" & tCurrentNum & ".nef"
        with timeout of 300 seconds
            open alias filePath
        end timeout
        set wDocRef to current document

        -- Make a selection
        set rightEdge to leftEdge + 4
        --              top left        top right           bottom right            bottom left
        set shapeRef to {{leftEdge, 0}, {rightEdge, 0}, {rightEdge, 4288}, {leftEdge, 4288}}
        select wDocRef region shapeRef
        copy

        -- Paste the selection into the ultimate document
        set current document to uDocRef
        select uDocRef region shapeRef
        paste

        -- Close the image
        close wDocRef saving no

        -- Update the left edge position
        set leftEdge to rightEdge

    end repeat

end tell
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.