Easy Way to Automate Photoshop with Variables (Part 6)

Easy Way to Automate Photoshop with Variables (Part 6)

Our journey with Variables in Photoshop cannot be completed without to cover Method and Alignment options which are available when defining Pixel Replacement Variables. Those 2 options are giving us opportunity to instruct Photoshop how to handle pixels which will be used to replace existing ones on the layer in our document for which we have defined Pixel Replacement Variable.

In this tutorial I will use images from depositphotos.

What is the benefit of knowing Method and Alignment options


First of all, let me tell you that you can change Method and Alignment options on the fly while defining and after Variables are defined. You can experiment with both options, even when using external files with Data Sets which are defined in advanced. We haven't covered yet external Data Sets but it is worth to mention.

Let me give you one example: you have image which you want to import as it is without any scaling during replacement. You want top left corner of the image to be at X=200px and Y=350px. You can draw a rectangle or square with only attention where is positioned top left pixel of that shape. Specify Method > As Is, Alignment anchor to top left and navigate to the image. Image will be placed with original dimensions and original proportions without any scaling exactly where you want it.

Another sample is that you want to use Fill Method but the image is not displayed as you want it due to anchor point set for Alignment. Change anchor point and bring in focus part of the image which is important or you want the viewer to see it.
Difference between center and bottom middle anchor point

What is Method in Photoshop's Variables dialog and how it works


Method in the Variables dialog refers to scaling of image or file which will be used to replace pixels on layer for which you are defining Pixel Replacement Variable. There are 4 choices: Fit, Fill, As Is and Conform.

Fit method instructs Photoshop to scale image which will be used for replacement. Both sides: Width and Height must be equal or smaller than Width and Height of shape on layer for which you are defining variable. Usually one side is equal and other is smaller than. Both sides can be equal but not and smaller than. Original proportions will be maintained or constrained.
Fit method in Variables dialog in Photoshop

Fill method instructs Photoshop to scale image which will be used for replacement by both sides. Width and Height must be equal or greater than Width and Height of shape (pixels) on layer for which you are defining variable. Both sides can be equal but not and greater than. Original proportions will be maintained or constrained.
Fill method in Variables dialog in Photoshop

As Is method instructs Photoshop to import image as it is without changing pixel dimensions. Here is one note: when you work with Pixel Replacement Variables, document resolution which is set in the Resolution field in the Image Size dialog does not play any role. The only thing that counts are the pixel dimensions (900px X 600px for example).
As Is method in Variables dialog in Photoshop

Conform method instructs Photoshop to replace pixels on a layer without to worry about original proportions what can result with a distorted image.
Conform method in Variables dialog in Photoshop

What are Alignment options in Variables dialog

Alignment options in the Variables dialog instructs Photoshop to match centers/corners of replacement image with the centers/corners of the shape on the layer for which you are defining Variable.

When referring to shape I do not mean vector shape. You can count as shape whatever you have on the layer: rectangle, rounded rectangle or stroke painted with any of the brushes will result with pixels on layer which can be referred as a shape.

Here I will stop for a moment. Some of you may ask: we are defining Pixel Replacement Variables in the previous five posts with Variables in title and all the time we are working with vector based layers or vector shapes! How that works, why we do not have vector replacement variables? Because two reasons:

  • Regardless of file type you choose to use for replacement it will be rasterized during the replacement process. 
  • Vector shapes are always filled with solid color pixels, gradients(again pixels) or seamless tiling patterns (again pure pixels).

Back to Alignment options which are represented as nine squares which are actually anchor points. Anchor points refer to pixel in:

  1. Top left corner of the layer (shape or pixels on layer)
  2. Top middle
  3. Top right corner
  4. Middle left
  5. Center
  6. Middle right
  7. Bottom left corner
  8. Bottom middle
  9. Bottom right corner

You can manually set anchor point which is represented with white color while other anchor points (not in use) are represented with gray color.

Here is how things work: if you specify Fill Method and top left anchor point to be used, then Photoshop will import the image, scale it to fill available space and place top left pixel of imported image in the exact position in the document where is located top left pixel of the shape on layer for which is defined Pixel Replacement Variable.
Fill method with top left anchor point set for Alignment

Keep in mind one thing when you have free form shapes: except for As Is and Fit methods, every pixel on the layer for which you have defined a Pixel Replacement Variable must be replaced and covered with pixels from the specified source. The pixels used for replacement can be color pixels, transparent or semitransparent pixels.
Top left anchor with Fill method
Example with Top Left anchor point and Fill method. In this case the top left pixel of replacement image will not be at the exact same location as the top left pixel on layer due to Fill method which requires all pixels on the layer to be substituted (replaced).

Clip to Bounding Box options

There is one more option worth to mention and that is Clip to Bounding Box. This option is available for Fill and As Is methods. Simply speaking clip means actually crop. Placed pixels will be cropped to bounding box which are actually the edges of a shape on layer for which is defined variable. This option can be useful when using As Is method in case you want to crop images for replacement without to scale them. When using Fill Method, placed image may be larger then defined space in case proportions of pixels on layer and replacement image does not match.
Clip to Bounding Box option in variables dialog in Photoshop

Workaround to not crop pixels when using both methods: As Is and Fill is to clip the layer with the replacement image to layer below (clipping mask). For me it is the preferred way to work because you will get extra flexibility to move placed image and tweak what is visible in case you are not completely satisfied. I am naming layers to which is clipped layer with a replacement image as placeholders (screenshot below).
Clip layer with variable to placeholder layer below

Practice what you have learned

After reading this tutorial go back and read again first tutorial in this series. After specifying which image to use for Pixel Replacement click on the Previous button in Variables dialog and change Method and Alignment to see what final results you can get.

Note: after changing Method and Alignment options click on the Next button to load dialog with Data Sets.
Method, Alignment and Next and Previous buttons in Variables dialog in Photoshop


Conclusion

Method and Alignment options can be very important as you can see from the post above. It is easier to plan and work with Variables (actually Data Sets) when you know all the options available to you. Experiment a bit with Method and Alignment and you will add more options and more flexibility to your Photoshop automation skills.

All posts in this mini-course
Easy Way to Automate Photoshop with Variables
Easy Way to Automate Photoshop with Variables (Part 2)
Easy Way to Automate Photoshop with Variables (Part 3)
Easy Way to Automate Photoshop with Variables (Part 4)
Easy Way to Automate Photoshop with Variables (Part 5)
Easy Way to Automate Photoshop with Variables (Part 6)
Easy Way to Automate Photoshop with Variables (Part 7)
Why and How to Combine Text/Pixel Replacement Variables With Visibility Variables in Photoshop

Product used in this tutorial:
Adobe Photoshop CC 2014

Reference:
Photoshop Help / Creating data-driven graphics

Comments

Popular posts from this blog

Free Puzzle Pieces Actions For Photoshop and Elements

How to Change Artboard Size in Adobe Photoshop

Old Weathered Vertical Wooden Planks Free Image