Batch subfolder images to layer stacks, then to sprites.

I have tried for nearly a week now to wrap my head around this one but I'm a just too new to java scripting to pick it up soon enough to solve my problem. I found Batch HDR creation script, which was great and close to what I'm looking for but I'm not sure how to put it all together. I'm hoping, no begging for some help.
Ok....
So I have animations for a game rendered into png image sequences placed into separate folders that contain customizable armor and weapons that can be added on top of the character upon the gamers selection.
There are 130 total character animation folders and 209 separate subfolders inside the animation folders containing the custom armor and weapons following the character.
The original idea was just to give the programer image sequences but it has changed to require sprite sheets now, and that leaves way too many manual conversions to cover in the time I'm allotted.
I need a script that makes you browse for the top folder(the animation)one time then opens all subfolder images one folder at a time into layer stacks, then converts them to sprite sheets, saves them out as a png with transparency to a separate folder containing all created sprite sheets from the animation folder in one new folder or already created folder on the desktop.
I mashed some well thought out(not mine) scripts together but couldn't get them to batch open subfolders and the layers to sprite would return an error because some frames are blank.
I'm using Photoshop CS5 and Mac osx, this is my first forum post anywhere, ever, so exciting. Thanks for any advice or help.
Dev

// select folder, create files with the contents of one of the subfolders each as layers and save them to the folder;
// use it at your own risk;
#target photoshop
// select a folder;
var sourceFolder = Folder.selectDialog("Select folder");
if (sourceFolder) {
// the psd options;
psdOpts = new PhotoshopSaveOptions();
psdOpts.embedColorProfile = true;
psdOpts.alphaChannels = false;
psdOpts.layers = true;
psdOpts.spotColors = true;
// get the contents as one array per folder;
var items = retrieveFiles(sourceFolder, [[]]);
// iterate through;
for (var m = 1; m < items.length; m++) {
          var thisArray = items[m];
          var folderName = thisArray[0].parent.name;
// open file;
          var theImage = app.open(File(thisArray[0]));
          for (var n = 1; n < thisArray.length; n++) {
// place rest of array;
                    var theLayer = placeScaleFile(thisArray[n], 0, 0, 100);
// Arrange layers into a sprite sheet.   
if (documents.length > 0)
          var cols = 5;
          docRef = activeDocument;   
          var activeLayer = docRef.activeLayer;
          numLayers = docRef.artLayers.length;
//           layertext = "There are " + numLayers + " layers.";
          var rows = Math.ceil(numLayers/cols);
           var spriteX = docRef.width;
           var spriteY = docRef.height;
          // put things in order
          app.preferences.rulerUnits = Units.PIXELS;
          // resize the canvas
           newX = spriteX * cols;
           newY = spriteY * rows;
           docRef.resizeCanvas( newX, newY, AnchorPosition.TOPLEFT );
          // move the layers around
           var rowi = 0;
           var coli = 0;
           for (i=(numLayers - 1); i >= 0; i--)
                     docRef.artLayers[i].visible = 1;
                      var movX = spriteX*coli;
                      var movY = spriteY*rowi;
                     docRef.artLayers[i].translate(movX, movY);
                     coli++;
                     if (coli > (cols - 1))
                               rowi++;
                               coli = 0;
//This is to merge the visible layers/////////
try{
    activeDocument.mergeVisibleLayers();
    }catch(e){}
// save the stacked file;
          theImage.saveAs(new File(sourceFolder+"/"+folderName+".psd"),psdOpts,false);
// close;
          theImage.close(SaveOptions.DONOTSAVECHANGES);
////// get from subfolders //////
function retrieveFiles (theFolder, theFiles) {
          if (!theFiles) {var theFiles = [[]]};
          var theContent = theFolder.getFiles();
          for (var n = 0; n < theContent.length; n++) {
                    var theObject = theContent[n];
                    if (theObject.constructor.name == "Folder") {
                              theFiles.push(new Array)
                              retrieveFiles(theObject, theFiles)
                    if (theObject.name.match(new RegExp(/\.(jpe|jpg|jpeg|gif|png|tif|tiff|bmp|psd|dng|pict|eps|raw|rw2|crw|cr2)/i)) != null) {
                              theFiles[theFiles.length - 1].push(theObject)
          return theFiles
////// get psds, tifs and jpgs from files //////
function getFiles (theFile) {
    if (theFile.name.match(/\.(eps|ai|jpg|tif|psd|pdf|)$/i)) {
        return true
////// place //////
function placeScaleFile (file, xOffset, yOffset, theScale) {
// =======================================================
var idPlc = charIDToTypeID( "Plc " );
    var desc5 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    desc5.putPath( idnull, new File( file ) );
    var idFTcs = charIDToTypeID( "FTcs" );
    var idQCSt = charIDToTypeID( "QCSt" );
    var idQcsa = charIDToTypeID( "Qcsa" );
    desc5.putEnumerated( idFTcs, idQCSt, idQcsa );
    var idOfst = charIDToTypeID( "Ofst" );
        var desc6 = new ActionDescriptor();
        var idHrzn = charIDToTypeID( "Hrzn" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc6.putUnitDouble( idHrzn, idPxl, xOffset );
        var idVrtc = charIDToTypeID( "Vrtc" );
        var idPxl = charIDToTypeID( "#Pxl" );
        desc6.putUnitDouble( idVrtc, idPxl, yOffset );
    var idOfst = charIDToTypeID( "Ofst" );
    desc5.putObject( idOfst, idOfst, desc6 );
    var idWdth = charIDToTypeID( "Wdth" );
    var idPrc = charIDToTypeID( "#Prc" );
    desc5.putUnitDouble( idWdth, idPrc, theScale );
    var idHght = charIDToTypeID( "Hght" );
    var idPrc = charIDToTypeID( "#Prc" );
    desc5.putUnitDouble( idHght, idPrc, theScale );
    var idLnkd = charIDToTypeID( "Lnkd" );
    desc5.putBoolean( idLnkd, true );
executeAction( idPlc, desc5, DialogModes.NO );
return app.activeDocument.activeLayer;

Similar Messages

  • Labeling all images in a stack; when all images are stacked

    A long time ago, when I was using Photoshop Elelments I found a plug-in that made it possible to work with stacks as a unit. 
    If I labeled the top image in the stack that lable was applied to all the images in the stack; then I could sort the the image on top and all the images in the stack would stay together, or if I deleted an image in the stack all the images in the stack were deleted.  Without it I have open each stack I lable and apply the lable, so when I sort the stacked images they stay together.
    I don't remember where I found that plug-in and I'm sure it would work in Photoshop.  Anyone else use it and know where I can find it?

    I do not use Lightroom when you wrote "Stack" in Photoshop that refers to the layer stack.  The link you posted seems to be more about paring files.  I do not know much about lightroom except it organizes your images using logical databases. Lightroom calls this its Library system.  I know the book libraries have book stacks so it would surprise me that Lightroom had some type of stacks.  You started by stating when you used PSE you used something to manage stacks.  I thought now the you are using PS you needed something for it.  This thread most likely belongs in the Lightroom forum.

  • Applying labels to all images in a stack

    A long time ago, when I was using Photoshop Elelments I found a plug-in that made it possible to work with stacks as a unit. 
    If I labeled the top image in the stack that lable was applied to all the images in the stack; then when I sorted the images, the stack remained in tact; instead of just the top image, with the label showing up. I could also label the top image in a stack with flaga and, for example quickly delete all the image with an "X". Oterwise is seems the only option is to open each stack, by Ctrl-clicking the number in the upper left corner, that opens the stack; with all the images selected, then click the star lables I want to apply to all the images in the stack.
    I don't remember where I found that plug-in.  I'm hoping the guy who wrote it; and all I can remember about him is that he was from England, has written a version for Lr?

    I love a man with a sense of Humor
    Your the man!  Thanks so much.  I bracket all my shots and load them into the  HDR editor in Ps; my workflow will go so much smoother now.

  • I recently upgraded our iMac to Yosemite OS and now have a problem with Photoshop Elements 11:  the move tool selects an image or text layer, but then I try to drag the selection somewhere else on the page and it snaps back to the original location, howev

    I recently upgraded our iMac to Yosemite OS and now have a problem with Photoshop Elements 11:  the move tool selects an image or text layer, but then I try to drag the selection somewhere else on the page and it snaps back to the original location, however the arrows will move it OK.  Also I cannot drag the selection to another photo in the photo bin as before.

    Hi,
    Please refer: http://helpx.adobe.com/photoshop-elements/kb/pse-stops-responding-yosemite.html
    Thanks,
    Anwesha

  • Script to open a multi-image TIFF into a layer stack?

    I have a colleague who has multi-image TIFF files, each of which contains a series of images of microscopy sections. He needs Photoshop (Mac version) to read these files, and place the multiple images into a stack of layers in one document.  We have found indirect ways of doing this, but they require multiple applications and several steps.  Is it possible to create a Photoshop script that does this directly: opening the multi-image TIFF, parsing the file, and loading the images into layers?  Does such a script already exist?  If not, can you point us toward source code samples that will help us build the script: perhaps snippets for parsing a multi-image TIFF, and initializing a document with multiple layers.
    Thank you.

    Chris Cox wrote:
    I've been trying to find a good way to handle multi-image TIFF files without excessive slowdowns and problems -- and haven't found a good solution yet.
    The ability to open other than the first page of a multi-page tiff would be welcome. Even if each page is opened as a separate document. Something similar to the way PDF files are handled now.
    Once all the pages of the tiff file where open the user could then choose the colorMode, bitDepth, etc to use if they wanted to combine the pages into one doc as layers. And as Xbytor points out if smart object layers are used there would be no need to convert when combining.

  • CS5 Batch Via Image Processor Fail

    Hi All, I have  batch problem in CS5 using the Scrips/Image Processor feature. I have an action which does the following to a folder of selected images (jpegs): Creates a duplicate layer, runs Portraiture on the image, creates a new layer on top of Portraiture via a layer combination, then runs Alien Skin Exposure film simulation filter. The problem is that after 144 images process, normally the 144th or 145th image will fail to close. The remaining images will open and close (and save in destination folder) but the action is not applied to those remaining images. If I stop the batch and restart, it will immediately fail again. Photoshop must be closed and repoened in order for me to process remaining images (up to 144). My source images are normally (2-4mb) jpegs and I am saving the batched images as either jpegs or psd's. Either way fails. I am running CS5 with the most current update on a 2010 MacPro (12gig) with OSX 10.7.4 installed. Please help!  

    When you installed CS5, you have a chance to register it. If you do, your serial number is on file under your Adobe (My Products). If you did not, you have no serial number on file and even worse, no proof you own it.
    You do not have your serial number copied down anywhere? Hard to believe you tossed the dvd box and all the documents away.
    So Help > Register might give you a chance to do this without you knowing the number.
    If not, you may want to consider the Photography Plan. Creative Cloud Photography plan | Adobe Creative Cloud

  • Sort by number of images in a stack

    I use stacks a great deal, we have the ability to sort by rating, by picks, by date, etc etc, a very useful way would be to sort by number in stack.
    I stack images and then batch process so say a selection of 27 images arranged in stacks of 3, followed by a selection of 12 images arranged in stacks of 4.
    This would make my work flow so much faster, that or a way to select all the images in a stack, like cmd click top image to select all in the stack, that would work, providing I was then able to cmd click another stack and select all those images as well.

    is there a limit in the number of images in a folder? the number of images in a slide show?
    None that I know off. But why are you asking? Did you notice any performance problems or problems to render the slideshow? Then it would help to know more about your hardware RAM, disk, CPU ..
    If you already encountered problems, you may wish to have a look at this thread - although it relates to Aperture 3, not 2:
    Is there a limit on the number of photos you can use in an Aperture slideshow?
    And as I said in that thread:
    I'd expect the limiting factor to the length of a slide show to be the patience and "Good Will" of your intended audience
    Regards
    Léonie

  • Batch transforming images

    Hi,
    I am evaluating if photoshop can help me save loads of my image transforming time.
    I need to automate the process of warping image files based on predefined custom warp. Example- a batch process to read an image file, then select the warp layout (if image is a scenery then warp is a custom coffee cup, if image is logo then warp is a custom warp of a watch). I will be making the warp layout myself.
    I have the logic of identifying the content in the image sorted.
    Now will PS scripting allow me to make a custom warp and then apply in batch?
    If yes, please suggest if I can see an example or read a document somewhere.
    Thanks in advance for your help.
    Ash

    You could use scriptlistner (it ships with Photoshop) to make a function for each of you custom warps. But it will be recorded in pixels so all of your images will be need to be the same. Or have the script adjust the function for the differences in size.
    While it is true that there are only 4 points, you can click and drag anywhere in the bounding box to edit the warp.
    You could also make a template by warping a smart layer. Then all you would need to do is replace the smart objects contents by choosing Layer->Smart Objects->Replace Contents. The new contents will have the same warp. But again the images need to be the same size.
    Mike

  • In Bridge CS6, the "Tools" tab is missing the "Photoshop" option to batch process image

    Hello!
    Does anyone know why in Bridge cs6 under the "Tools" tab, my "Photoshop" option is missing?  That is how I have always batch processed images.  In Bridge, I choose the images to process, go to the "Tools" tab, down to the "Photoshop" option then to "Image Processor" and process.  Now when I go into my "Tools" tab it only has the options: Batch Rename, 4 kinds of Metadata related options and Cache.  Can someone tell me why this has happened and how to fix it?  Thank you!!!
    Eric

    Hello Omke,
    This problem lasted for two days.  I tried many suggestions but nothing worked immediately.  Suddenly I turned my computer on last night and it was fixed...inexplicably.  Not sure what worked but something did.  I appreciate you taking the time to offer advice. 
    Best,
    Eric

  • How do I copy only the flagged image in a stack to an album?

    Within a project containing many stacks, I want to make an album showing only flagged images from some of these stacks. But when I try to do this, I end up with the stacks in the new album - which is not what I want.
    For example, from a small gathering I have 94 photos in 24 stacks. (Among other things, I auto-bracket.) The correct image is the "pick" in each stack. I flagged 8 photos and uploaded them to a Picasa Web Album, for people to see. I want to make an album inside the project showing only the photos I uploaded, but I have not found how to do this.
    I can view the 8 flagged photos by filtering, and though each has a badge showing the number of photos in its stack, the remaining photos do not appear if I click on the badge or press Shift-K or select Open/Close Stack: all that happens is that the badge toggles between the number of images in the stack ("x") and "1 of x" - say, between "4" and "1 of 4", if there are 4 images in that stack.
    But when I put a flagged image into an album, I get its whole stack. It does not matter whether I drag it or choose New > Album and click the "Add selected items to new album."
    This seems like such an obvious task that I feel I must be missing something.
    Any help?

    Just to expand on Frank's answer: that's how Aperture works.  Stacks travel together.  You will see the same behavior regarding filtering in the Album that you see in the Project.  (Album is a container.  As with a Project, you can filter the Album container to show only items that meet your filter criteria, but the contents of the container don't change by being filtered.)
    This is why Album picks are so useful.  In Projects, the Stack Pick is the left-most Image in the Stack, and is the Image that shows when the Stack is minimized.  In Albums, you can specify an Album Pick.  (The default Pick is the Stack Pick.)  When a Stack in an Album is collapsed, the Album Pick is the Image that shows on top.
    Added the following paragraph:
    So you could have a Project with Stacks of bracketed exposures (an excellent use of Stacks), you could make the best of these the Pick, and then you could make an Album showing, say, the second best ones by putting them in an Album and designating the second-best Images as the Album Pick of each Stack.
    You should have no trouble creating an Album of your selected Images (in this case, you are selecting by "is flagged").  With Stacks collapsed, you should see what you seem to want, which is a group of the Images you selected to be in the Album.
    denke wrote:
    I want to make an album inside the project showing only the photos I uploaded, but I have not found how to do this.
    That the rest of the Images in the Stack are there shouldn't be a concern.  Why is it?
    Message was edited by: Kirby Krieger

  • Can I put only the top image of a stack in a Mobile Album?

    I have an album that contains stacks and I would like to put only the top images of these stacks in a Mobile Album.  Is this possible? 
    I have tried to make a new album and only put the top images in this new album without sucess.  Is it possible to have a stack of images in one album and only the top image in another ablum?
    I hope someone knows about this
    Hans Brodin

    Hi Surendra,
    My target is to find a convenient way to transfer my best photos only to my iPad
    By using stacks for similar photo and putting my best shot on top I reduce the number of images displayed in the organizer.  A typical stack contains of 8 shots.  
    Then I put my best stacks in an album.  By using the Slide Show in PE I have a convenient way to display only my best shot and tha's OK for my computer were I have a lot of disc space.
    But on my iPad the size of memory is limited and it also takes some time to transfer a huge number of images so now I want to find a convenient way of tranfering only the top image of each stack. If I could have a separate album containing only the top images from each stack the task would have been easy.
    Now this is not possible so now I hope there is another solution than acually making a separate copy (a new file) of each top image and put these copies in a separate album.   This will of course work but it will end up in having two identical images showing up in the organizer and so I do not really like this idea.
    I hope I have managed to describe my intention and do you have an idea for a workaround or do I need to make separate copies?
    Thanks a lot
    Hans

  • After creating a mask on a pixel layer and then throwing it away, the pixels disapper

    If I create a mask on a pixel layer and then throw the mask away, the pixels under the old black mask disappear. Help! How do I fix this? I have already reset preferences. I am using the most current version of Photoshop CC 2014 on a Mac with OS 10.9.5

    Or just leave the layer mask in place.  It's a valuable recourse that you might need to use again.  The layer mask exists as an alpha channel.  It's there in the Channels panel when you click on the layer that contains the layer mask.  You might want to restrict an adjustment layer to the same area, or the inverse of that area.  It's not always convenient to do that by clipping — you might be targeting a layer way up the stack.
    OK, you can Ctrl click the layer if you removed the mask by Applying it, but it feels just plain wrong to me to throw a hard won selection in the dustbin.

  • Sorting of images within a stack

    When working with stacks some strange things happen:
    - When trying to duplicate one image out of the stack into an album the whole stack is moved to the album. When I than delete this stack in the album the order of the images of the same stack in my projects is changed.
    - When rejecting images within a stack my rejected images are not automatically moved to the rejected images folder. Instead these images stay in the stack even so they are marked as rejected.
    - When sorting images within a stack by using different ratings and than trying to limit the image view by showing for instance only images with 3 stars or more nothing happens. Also showing rejected images only does not work within a stack. Instead showing images by rating is applied to the whole project and not only the stack
    Do I do something wrong or is this a known apperture bug?
    MBP   Mac OS X (10.4.9)  

    David, your understanding (use) of stacks is causing a conflict. The whole idea is basically to group a series of similar images and choose the best one of that series, called the Pick. Then, within that series you can rank those images in an order of Pick to next best, and so on. You can view stacks open or closed - when closed, the Pick is the one on top.
    Here's some info from the Help Menu that will help answer your questions:
    Note: When you place a stack in a book album or web gallery or web journal album, Aperture displays the stack pick. If you drag a stacked image that is not the stack pick into the book or web gallery or web journal album, Aperture reminds you to select the stack pick. If you don’t want to place the pick in the album, but want to use a different version from within the stack, select the version you want and then make it the album pick by choosing Stacks > Set Album Pick.
    Dragging Stacks
    You can drag an entire stack to a new location, and you can drag specific images within a stack to a new location. When a stack is closed, dragging the stack moves the entire stack. When a stack is open, you can drag individual versions to new locations in the Browser. You can also drag images into a stack. If you drag a stacked image into a different project, however, the entire stack moves to the new location.
    If you still want to be able to use a stacked image as you have stated, then take that image out of the stack, split the stack, or create a version of the image and remove it from the stack.
    Take a quick refresher through the help menu - it will give you some further details and ideas so you can accomplish exactly what you need to do.
    Hope that helps!!

  • Batch load images (tiff) into table with a BLOB column

    Hi,
    Does anyone know any third-party tool/software to bulk/batch load images into Oracle table? There is an ETL software to regularly pull the images (tiff) from a ftp server to a directory in the database server. There is no way I can hardcode the image filenames into the control file and use SQL*Loader to load the files. Is there any tool/software that can just grab whatever files in the directory and load them into Oracle. Then, I can write a program to extract the filename from the file already loaded into the table and update the filename column.
    Thanks.
    Andy

    sound like simple scripting to me...
    -- SQL loader example
    http://www.orafaq.com/wiki/SQL%2ALoader_FAQ#How_does_one_use_SQL.2ALoader_to_load_images.2C_sound_clips_and_documents.3F
    -- dynamically build control file
    devuser1:/tmp>>touch image1.gif
    devuser1:/tmp>>touch image2.jpg
    devuser1:/tmp>>touch image3.jpg
    devuser1:/tmp>>ls -l image*
    -rw-rw-r--   1 devuser1   mygrp           0 Jul 10 11:19 image1.gif
    -rw-rw-r--   1 devuser1   mygrp           0 Jul 10 11:19 image2.jpg
    -rw-rw-r--   1 devuser1   mygrp           0 Jul 10 11:19 image3.jpg
    devuser1:/tmp>>ls -l image* | awk '{ print NR "," $9}'
    1,image1.gif
    2,image2.jpg
    3,image3.jpg
    devuser1:/tmp>>echo "LOAD DATA" > t.ctl
    devuser1:/tmp>>echo "INFILE *" >> t.ctl
    devuser1:/tmp>>echo "..." >> t.ctl
    devuser1:/tmp>>echo "BEGINDATA" >> t.ctl
    devuser1:/tmp>>ls -l image* | awk '{ print NR "," $9}' >> t.ctl
    devuser1:/tmp>>cat t.ctl
    LOAD DATA
    INFILE *
    BEGINDATA
    1,image1.gif
    2,image2.jpg
    3,image3.jpgEdited by: maceyah on Jul 10, 2009 12:42 PM

  • Selecting images in a stack v1.0

    is there a shortcut to 'select all' in a particluar stack, then choose develop module to work on this selection only?

    If you click on the white square on the stack, (the square showing the total number of images in the stack), the stack will expand and all images will be selected.
    Now press D to go to develop and use Auto Sync to work on all images at once.
    (Command click on the Sync button in the right hand panel in Develop to change the state to Auto Sync).

Maybe you are looking for

  • Unable to Connect to iTunes Store for Apple TV Purchases

    For the past 2 days I have been unable to make purchases from the iTunes store with Apple TV. I get the message "Unable to connect to iTunes Store. Temporarily unavailable. Try again later."  Despite this message, I have a valid internet connection a

  • Original iPad no longer connects to Mac?

    My original iPad will no longer connect to my Mac. I replaced my old Mac Tower with an Intel Power Mac. I have tried everything that I can think of to remedy this problem.

  • Mail.app not decoding MIME attachments correctly

    I have a security camera that e-mails me a video clip whenever a security event happens.   I have these events e-mailed to a linux server to a private e-mail account.  From time to time, I use Mail.app on my Mac to review the video clips by opening t

  • Playback of .f4v files

    I have a live feed that i am streaming with adobe flash media live encoder 3.1. I am saving the files as .f4v, how do i play them? i have tryed to use both embedding and every flash player under the sun as well as adobe cs5. can anyone help me with t

  • IWork (number) lags after Snow Leopard upgrade install

    My dad upgraded his mac with SL. After he did his iWork and iLife started lagging really bad. When he opens a large numbers spreadsheet, it takes a very long time to load. Activity monitor shows 98% use and application not responding. If you wait lon