0

I have a set of transparent PNGs all loaded (stacked) into a single PSD file. Each layer contains a different shape and each occupies a very specific location in a 256px square which has a transparent background.

I want to perform an operation that is very similar to what Layer > Distribute > Left Edges does. Except when I tell it to align the left edges, it doesn't use the left edge of the 256px square, it uses the leftmost pixel of each opaque shape within each layer. As a result, all the images get shifted from their specific location.

I need them to maintain their original positions so that when I load them as a sprite sheet into an HTML5 website and present them consecutively in the same spot, they don't appear to shift. Think of them as frames in an animation.

I have 60 such images in each of 8 separate stacks. Once I have them distributed horizontally, I want to take each of those and merge and distribute them vertically so that I have a complete sprite sheet with 8 rows and 60 columns of different images.

My problem is the distribution step. How can I get it to consider the transparent space in each image when calculating the spacing?

Said differently, I want to shift each layer so that:

  • layer 1: 0 pixels to the right
  • layer 2: 256 pixels to the right
  • layer 3: 512 pixels to the right
  • layer 4: 768 pixels to the right
  • etc...
  • layer 60: 15104 pixels to the right

I am using PS CS6.

Not all images are the same shape. Some might fill 200px horizontally, while another might fill only 50px, for example.

2
  • ...or just do it in python. even though I practically forgot python syntax completely, I solved my problem in about an hour
    – Octopus
    Commented Apr 11, 2018 at 3:57
  • I wonder if downvoter's would kindly explain?
    – Octopus
    Commented Apr 11, 2018 at 16:47

1 Answer 1

1

Highlight the layer (or group) in the Layers Panel.

Choose Edit > Transform > Free Transform (Command/Ctrl+t)

Enter a revised value in the X or Y field in the Control bar across the top of the screen.

enter image description here

  • X - Positive numbers to move the layer right, negative numbers to move the layer left.

  • Y - Positive numbers for downward, negative numbers for upward


So, to move a layer 512px to the right, you would....

  • Enter [existing value] + 512px into the X field and then hit the Enter key
    (Enter key twice actually-- once to commit the position change, then once again to commit the transform function)

So, based upon this...

enter image description here

Input 572px (60 + 512) for the X field and hit Enter twice.


Note: In Photoshop CC you can also use the Properties Panel to input X and Y positions. I can't remember if that existed in CS6.

3
  • Yes. Or instead of putting [exiting value]+512, it would be much easier to click the left side as the anchor and enter 512. Then you go through each element and enter all of the numbers and calculate each one as you go. With 60x8 different elements that's a total of 480 individual manually entered numbers. Which isn't only tedious it lends itself to error. Only one error would render the entire job useless and I'd have to either figure out which ones are wrong and by how much or just start over. Its a shame Photoshop doesn't have better scripting capabilities.
    – Octopus
    Commented Apr 11, 2018 at 16:46
  • I was intentionally trying to avoid "free transform" by finding a way Photoshop would calculate this large number of values for me.
    – Octopus
    Commented Apr 11, 2018 at 16:50
  • Actually, I think a great deal of the problem is Photoshop's lack of any real distribute spacing options. I wasn't considering scripting.. and I wasn't considering hundreds of layers :) Merely providing a method which does work.. although I agree, it can be tedious with many, many layers.
    – Scott
    Commented Apr 11, 2018 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.