Monday, May 18, 2015

Photoshop Batch - Add incremental serial number on image


I'm a Photoshop newbie



My goal is to add a specific serial number (S/N IO 0001, S/N IO 0002, S/N IO 0003) on the same image and export it as jpg such as "img_sn_0001.jpg", "img_sn_0002.jpg", "img_sn_0002.jpg" etc..


Is it possible to do this in Photoshop?


Or is there another way to do this?



Answer



Yes, its possible to do. However, I would suggest you learn to use imagemagick or any of the derivatives/clones of this project. Simply because its designed for this, faster and much more widely deployed (even my phone has it). Also simply for the reason that you can find examples of imagemagick doing just this while for Photoshop there are far less instructions and its much more convoluted. I'm sure you can manage to find a imagemagick script that does just this. Also you may find that something like llustrator and even inDesign are much better suited for this task.


But back to the topic how would you do this in Photoshop. You would use jsx scripts for this, the topic is quite wide so i will just guide you to a solution not the ultimate solution. At the end of the day how you want to architect your productivity tools is up to you. Im going for a sane customization option but you might want to go to hands off option.




  1. Open the image you want to manage. Then add a text layer on top of it place this text wherever you want the label to be set the font etc. For the script below to work the text must be the topmost layer in the stack





  2. Open ExtenScript toolkit, it is a separate program installed as part of any adobe design application.




  3. In the source 1 window type (or copy):


    #target photoshop


    doc = app.activeDocument;
    for (var i = 1; i <= 10; i++){

    doc.layers[0].textItem.contents = "S/N IO "+ padding(i, 4);

    // JSX uynderstands / as OS dependent so on windows you can
    // use / as separator despite it really being \ but / is less typing
    tojpeg(doc, "C:/temp/img_sn_"+ padding(i, 4), 6)

    // app.refresh(); // if you want to see each one. It does slow things down.
    }



    // Support functions
    function padding(num, length) {
    var str = num.toString();
    while (str.length < length)
    str = '0' + str;
    return str;
    }

    function tojpeg(doc, filename, quality){
    opt = new JPEGSaveOptions();

    opt.quality = quality;
    fp = File(filename);
    activeDocument.saveAs(fp, opt, true, Extension.LOWERCASE);
    }


  4. Change line with for to read whatever you want te max number to be instead of 10. Also change the tojpeg line to have the path you want.




  5. Press run (green arrow or F5)





No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...