15 Replies Latest reply on May 6, 2010 3:57 AM by GD_lewis

    Contact Sheet Automation

    lewis_cooper Level 1

      Hi everyone,

       

      You guys here have a 100% track record so far helping me out so I've high (desperate) hopes for this one...

       

      I work for a fashion catalogue and need to prepare a shoot plan for the photographer using the designer's original sketches. Scanning the artwork is out of the question as there are thick fabric swatches, that need to remain there, all over the sheet. My previous solution and rather effective one too, was to photograph them tethered from my camera and then bumping the levels. That part I have covered.

       

      The problem I have is that I'm going to need an automated way for each of the images to be placed into a Picture Box and have an adjacent Text Box be filled with the file name sans the file suffix (which I can do easily with a find and replace I guess). But ultimately I need to avoid having to type the filename into the box manually. I've attached an example sheet to help illustrate what I'm after.

       

      I'd be so grateful if you can help me here!

       

      Cheers,

      Lewis

        • 1. Re: Contact Sheet Automation
          Harbs. Level 6

          Take a look at the image catalog script which is installed with InDesign.

           

          Also, Bridge can build a contact sheet as well.

          • 2. Re: Contact Sheet Automation
            lewis_cooper Level 1

            Thanks for the quick reply Harbs.

             

            I've just had a look at my previous artwork (from last year) and have realised that there is an added complication. I forgot to mention that the the top and trousers are different files and thus would need the joining of several filenames. ie. Picturebox1+Picturebox2+Picturebox3 would need to result in Filename1_Filename2_Filename3 (I've listed 3 as occasionally there'll be a Jacket involved. If you know what I mean? I've updated my supporting graphic again.

             

            Does this make things impossible? Really appreciate any help.

             

            Cheers,

            Lewis

            • 3. Re: Contact Sheet Automation
              Harbs. Level 6

              Not impossible, but it'll take a custom script...

              1 person found this helpful
              • 4. Re: Contact Sheet Automation
                lewis_cooper Level 1

                Is that something you'd be able to help me with Harbs? Although I appreciate that you most likely have other things that are keeping you busy! If that is the case could you perhaps point me in the direction of another user on here that would be able to help?

                 

                Much appreciated either way.

                 

                Cheers,

                Lewis

                • 5. Re: Contact Sheet Automation
                  [Jongware] Most Valuable Participant

                  How about this javascript?

                   

                  if (app.selection == null || app.selection.length < 2)
                  {
                    alert ("Please, DO select just an empty text frame and one or more images...");
                  } else
                  {
                    filelist = '';
                    textframe = undefined;
                    for (i=0; i<app.selection.length; i++)
                    {
                      if (app.selection[i].hasOwnProperty("contents"))
                      {
                       if (textframe != undefined)
                       {
                         alert ("That's more than a single text frame. Seriously.");
                         exit(0);
                       }
                       textframe = app.selection[i];
                      } else
                      {
                        if (filelist == '')
                          filelist += app.selection[i].images[0].itemLink.name.replace(/\..+$/, '');
                        else
                          filelist += '_'+app.selection[i].images[0].itemLink.name.replace(/\..+$/, '');
                      }
                    }
                    if (textframe == undefined)
                      alert ("Got a lot of stuff but no text frame?");
                    else
                     textframe.contents = filelist;
                  }
                  

                  Select a text frame along with one or more images and run the script. The text frame will be emptied, and the list of image file names sans extension will magically appear inside it, separated by underscores.

                   

                  Copy, paste into the Extendscript Toolkit Editor that came with InDesign, save as "GrabImageNames.jsx" into your Scripts folder. When saved in the correct location, ID will immediately show it in the Scripts panel.

                   

                  [Edit] Added a final check for a valid text frame somewhere in the selection. :-P

                   

                  [Edit #2] Damn my busy brain. Additional note: it will only work with bitmap images -- TIFF, GIF, BMP, JPEG (PSD?), not with AI, EPS, PDF, WMF. Additional note #2: it mercilessly slices off everything after the first period, so if you may have filenames that contain multiple periods, scream and I'll take a look.

                  • 6. Re: Contact Sheet Automation
                    Harbs. Level 6

                    Jong, I see you're having fun with your alerts lately!

                     

                    LOL

                    Harbs

                    • 7. Re: Contact Sheet Automation
                      lewis_cooper Level 1

                      Jongware, you are a legend. That works amazingly well, thank you.

                       

                      Is there a way to have an alert that pops up and asks me to enter a character which could be placed at the end of each filename? The reason being is that because the same garment will be used multiple times throughout the document in different colours.

                       

                      At the moment the file name results in something like U192_U166, so I will still need to manually place a single character at the end of each code to identify which colour version of that code will need be used. So, using the previous screen grab as an example, U192F_U166A could also be needed as U192D_U166B elsewhere. Am I still making sense?

                       

                      As I can't assign the colour code to the filename of the tiff, is there a way to make the script stop and ask me to input a character before writing the next underscore? That would be amazing.

                       

                      Thanks so much for your help with this!

                      • 8. Re: Contact Sheet Automation
                        [Jongware] Most Valuable Participant

                        Heh heh heh

                         

                        (I'd really like using just HAL quotes! Makes your computer come alive.)

                        • 9. Re: Contact Sheet Automation
                          [Jongware] Most Valuable Participant

                          That would be sth like this:

                          if (app.selection == null || app.selection.length < 2)
                          {
                            alert ("Please, DO select just an empty text frame and one or more images...");
                          } else
                          {
                            filelist = '';
                            textframe = undefined;
                            for (i=0; i<app.selection.length; i++)
                            {
                              if (app.selection[i].hasOwnProperty("contents"))
                              {
                               if (textframe != undefined)
                               {
                                 alert ("That's more than a single text frame. Seriously.");
                                 exit(0);
                               }
                               textframe = app.selection[i];
                              } else
                              {
                             filename = app.selection[i].images[0].itemLink.name.replace(/\..+$/, '');
                                nwfilename = prompt ("Code name:", filename);
                                if (nwfilename == null)
                                  exit(0);
                                if (filelist == '')
                                {
                                  filelist = nwfilename;
                                } else
                                {
                                  filelist += '_'+nwfilename;
                                }
                              }
                            }
                            if (textframe == undefined)
                              alert ("Got a lot of stuff but no text frame?");
                            else
                             textframe.contents = filelist;
                          }
                          

                           

                          The text in the Confirm dialog is set by default to the actual filename; whatever you change it to will be inserted in the by-line.

                          If you select Cancel (or press Escape), the whole operation is aborted and nothing changes.

                          1 person found this helpful
                          • 10. Re: Contact Sheet Automation
                            lewis_cooper Level 1

                            Absolutely brilliant!

                             

                            It works an absolute treat, thank you so much Jongware!

                             

                            I'd love to learn to do this myself, I feel bad expecting others to help me out so freely. Although part of me suspects you enjoy the challenges !

                            • 11. Re: Contact Sheet Automation
                              GD_lewis Level 1

                              Hi Jongware,

                               

                              I've just found yet another use for this script that you put together for me last year. I'm not sure if you remember the thread but was wondering if you could help me modify it slightly.

                               

                              At the moment it takes the filenames from each of the selected link frames then outputs a text string in the last selected text frame. The only trouble I have is that at the moment I have no control over the order that the filenames are arranged. I get the impression that this script uses the order in which the items were first created in the document, ie. if I drew box X, then drew Z, then drew box Y my filename would result in X_Z_Y.

                               

                              Can you think of anyway I could have more control over this? For example, the script being 'aware' of the order in which I make my selection before executing the script?

                               

                              Thank you so much in advance!

                               

                              Lewis

                              • 12. Re: Contact Sheet Automation
                                [Jongware] Most Valuable Participant

                                Unfortunately, the selection array from InDesign does not honor the order in which you made the selection. You are correct in your observation it's the creation order that gets used. (And I remember a frantic discussion a couple of years ago, when this behaviour was actually changed by Adobe ...)

                                 

                                Refresh my memory, if you will: are the selected images always ordered left-to-right or top-to-bottom? If one of these, the file names could be sorted on x- or y-starting coordinate of the original frames.

                                • 13. Re: Contact Sheet Automation
                                  lewis_cooper Level 1

                                  Thanks for getting back to me so quickly. More often than not, the items will need to be listed in the order that they appear vertically from top to bottom, so your suggestion of making use of the y- axis would be ideal!

                                  • 14. Re: Contact Sheet Automation
                                    [Jongware] Most Valuable Participant

                                    Sure. How does this look?

                                    At first, I just added the y-coordinate to the file name list, but it bothered me the order in which the filenames appeared still was the original order (i.e., unordered). So I rewrote the thing, and -- learning something new every day -- decided to make it a nice 'basic' dialog.

                                     

                                    The Math stuff in the sort routine is because of an annoying "feature" I discovered: if the y-coordinates all line up, the objects should be sorted on their x-coordinate. However, it failed in my tests -- even though I selected all images and used "Align Top Edge"!

                                    Internally, InDesign uses something like 15 significant digits. I guess one image got palced with its top at 10.0000000000001 pt and the other at 10.0000000000002 pt ...

                                     

                                    //DESCRIPTION:Fashionable Labels
                                    // Jongware, 6-May-2010
                                    if (app.selection == null || app.selection.length < 2)
                                    {
                                     alert ("Please, DO select just an empty text frame and one or more images...");
                                    } else
                                    {
                                     filelist = '';
                                     textframe = undefined;
                                     framelist = [];
                                     for (i=0; i<app.selection.length; i++)
                                     {
                                      if (app.selection[i].hasOwnProperty("contents"))
                                      {
                                       if (textframe != undefined)
                                       {
                                        alert ("That's more than a single text frame. Seriously.");
                                        exit(0);
                                       }
                                       textframe = app.selection[i];
                                      } else
                                      {
                                       try {
                                        filename = app.selection[i].images[0].itemLink.name.replace(/\..+$/, '');
                                        framelist.push ([filename, app.selection[i].geometricBounds]);
                                       } catch (_)
                                       {
                                        alert ("No filename to retrieve, not an image!");
                                       }
                                      }
                                     }
                                     if (textframe == undefined)
                                      alert ("Got a lot of stuff but no text frame?");
                                     else
                                     {
                                      framelist.sort (function(a,b) { return Math.abs(a[1][0] - b[1][0]) < 0.001 ? a[1][1] - b[1][1] : a[1][0] - b[1][0]; });
                                      var myDialog = app.dialogs.add({name:"Fashionable Labels", canCancel:true});
                                      inputs = [];
                                      with (myDialog)
                                      {
                                       textEditContainer = dialogColumns.add();
                                       with (textEditContainer)
                                       {
                                        for (i=0; i<framelist.length; i++)
                                         inputs[i] = textEditboxes.add({editContents:framelist[i][0], minWidth:200});
                                       }
                                      }
                                      if (myDialog.show() == true)
                                      {
                                       textframe.contents = textEditContainer.textEditboxes.everyItem().editContents.join("_");
                                      }
                                     }
                                    }
                                    
                                    • 15. Re: Contact Sheet Automation
                                      GD_lewis Level 1

                                      From the few tests that I've just done this is exactly what I needed. I prefer the single dialogue entry box too!

                                      Thank you so much for going to all this trouble to re-write the code for me, I'm extremely grateful.

                                       

                                      Cheers,

                                      Lewis