Tile image in current place in Photoshop

100 Views Asked by At

Is there some methods (or scripts) to create repeated image tile in Photoshop(or other image editing software)?
Need to keep the image position and rotation.

From Image From

Target Image Tile: To

1

There are 1 best solutions below

2
Ghoul Fool On

The principle behind tiling is tessellation.

In your example, duplicating and moving a tile by a certain amount along it's local x axis (or as we see it, diagonally down and to the right) and then again for the y axis (down and to the left)

Load in the image and it will repeat the tile 12 times. You should then be able to adjust the script to your needs for other image.

enter image description here

// Switch off any dialog boxes
displayDialogs = DialogModes.ERROR; // OFF 

var originalUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;


var duplicatLayerName = "tile";
var offsetX1 = 215; // pixels
var offsetY1 = 111; // pixels
var offsetX2 = -103; // pixels
var offsetY2 = 178; // pixels
var numTilesX = 3;
var numTilesY = 4

// tile them along the x axis
for (var i = 0; i < numTilesX; i++)
{
  duplicate_layer(duplicatLayerName);
  transform(offsetX1, offsetY1, 0);
  // merge down as we go
  app.activeDocument.activeLayer.merge();
}

// now do the same for the y axis
for (var i = 0; i < numTilesY; i++)
{
  duplicate_layer(duplicatLayerName);
  transform(offsetX2, offsetY2, 0);
  // merge down as we go
  app.activeDocument.activeLayer.merge();
}



// Set measuring units back to how they were
app.preferences.rulerUnits = originalUnits;


// Set Display Dialogs back to normal
displayDialogs = DialogModes.ALL; // NORMAL


function transform(dX, dY, angle)
{
  if (angle == undefined ) angle = 0;

  //transform
  // =======================================================
  var id769 = charIDToTypeID( "Trnf" );
  var desc98 = new ActionDescriptor();
  var id770 = charIDToTypeID( "null" );
  var ref59 = new ActionReference();
  var id771 = charIDToTypeID( "Lyr " );
  var id772 = charIDToTypeID( "Ordn" );
  var id773 = charIDToTypeID( "Trgt" );
  ref59.putEnumerated( id771, id772, id773 );
  desc98.putReference( id770, ref59 );
  var id774 = charIDToTypeID( "FTcs" );
  var id775 = charIDToTypeID( "QCSt" );
  var id776 = charIDToTypeID( "Qcsa" );
  desc98.putEnumerated( id774, id775, id776 );
  var id777 = charIDToTypeID( "Ofst" );
  var desc99 = new ActionDescriptor();
  var id778 = charIDToTypeID( "Hrzn" );
  var id779 = charIDToTypeID( "#Pxl" );
  desc99.putUnitDouble( id778, id779, dX );
  var id780 = charIDToTypeID( "Vrtc" );
  var id781 = charIDToTypeID( "#Pxl" );
  desc99.putUnitDouble( id780, id781, dY );
  var id782 = charIDToTypeID( "Ofst" );
  desc98.putObject( id777, id782, desc99 );
  var id783 = charIDToTypeID( "Angl" );
  var id784 = charIDToTypeID( "#Ang" );
  desc98.putUnitDouble( id783, id784, angle );
  executeAction( id769, desc98, DialogModes.NO );
}


// function DUPLICATE LAYER (str)
// --------------------------------------------------------
function duplicate_layer(str)
{
  // duplicate layer
  // =======================================================
  var id1572 = charIDToTypeID( "Dplc" );
  var desc350 = new ActionDescriptor();
  var id1573 = charIDToTypeID( "null" );
  var ref184 = new ActionReference();
  var id1574 = charIDToTypeID( "Lyr " );
  var id1575 = charIDToTypeID( "Ordn" );
  var id1576 = charIDToTypeID( "Trgt" );
  ref184.putEnumerated( id1574, id1575, id1576 );
  desc350.putReference( id1573, ref184 );
  var id1577 = charIDToTypeID( "Nm  " );
  desc350.putString( id1577, str );         // layer name here
  var id1578 = charIDToTypeID( "Vrsn" );
  desc350.putInteger( id1578, 2 );
  executeAction( id1572, desc350, DialogModes.NO );
}

The result will be something like this that can be cropped. enter image description here