tile one or multiple images in larger specific dimension

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

christopherjohnson

tile one or multiple images in larger specific dimension

Post by christopherjohnson »

Hi I've been browsing the forum for a few weeks now working on some resizing scripts, calling actions, etc. and the forum has helped quite a lot since adobe's scripting guides are missing good examples.

Currently I'm looking for the following.

a script for taking open images (one or several) and placing them in one larger image for example taking images of 4500x3375, 4500x4500, 3375x4500, etc. and placing them in rows and columns to make something bigger for example that I could use as a shower curtain or bedspread design since my files aren't big enough so I'd need to make images around 8000x6000 depending on the product I'm designing for. some larger images need to be square others wider, others taller but fixed dimension (that I could set in the script)

so basically
1. resize canvas or new big image.
2. take current or all open files (PNGs and JPGs) and resize them to fit in rows and columns (tiled). I don't need borders or for them to be seamless although it would be nice to have the option. I want to either have the same image repeat or have them placed and aligned according to the image size like a granny square crochet blanket would have each square different.(but no I don't want to force non-square images to be square)
3... then I would save the image with a new name as a jpg (but no problem with that I know how to save images with javascript scripting.

You might tell me to do this with actions, but I'd have to make 20 versions or so if I did it that way...

I did some searches here and in Google and haven't found anything that works for me. Thanks in advance

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

kpt

tile one or multiple images in larger specific dimension

Post by kpt »

Don't know if this can be useful...

Code: Select all
/* tile current document NX x NY ways

    -  H -  H -  H - ...
    V HV V HV V HV V ...
    -  H -  H -  H - ...
    :

*/

var doc = app.activeDocument;
var iw = doc.width;
var ih = doc.height;

var NX = prompt("Number of tiles horizontally", 4);
var NY = prompt("Number of tiles vertically", 4);

// move layer l s.t. upper left corner is (x,y)
var moveLayerTo = function(l, x, y) {
  var cx = l.bounds[0];
  var cy = l.bounds[1];
  l.translate(cx - x, cy - y);
};


doc.selection.selectAll();
doc.selection.copy();
doc.resizeCanvas(iw*NX, ih*NY, AnchorPosition.BOTTOMRIGHT);
for (var y = 0; y < NY; y++)
  for (var x = 0; x < NX; x++) {
    if (x == 0 && y == 0)
      continue;
    doc.paste();
    var l = doc.activeLayer;
    moveLayerTo(l, x*iw, y*ih);
    if (y%2 == 0) {
      if (x%2 == 1)
        l.resize(-100, 100, AnchorPosition.MIDDLECENTER);
    } else {
      if (x%2 == 1)
        l.resize(-100, -100, AnchorPosition.MIDDLECENTER);
      else
        l.resize(100, -100, AnchorPosition.MIDDLECENTER);
    }
  }
christopherjohnson

tile one or multiple images in larger specific dimension

Post by christopherjohnson »

It is interesting, but I'm not really looking for any fancy effect. I just want to tile image(s) in a defined larger image using a script I can automate. thank you for sharing it.