0

If I state the purpose of my question as well as my question then hopefully this will be clear and why the other rather large range of answers on a similar topic aren't helpful.

Instagram uses square images in it's list, so I want to create a script to go into a folder of images and turn all of them into square images. But I don't want distortion or cropping. What I want is for the image to remain in the middle and the canvas to grow. Then any area that was added will be coloured either white or black.

I can do this manually but using the crop tool, telling it to be a square (ratio 1:1) and then dragging left to the edge and the right to it's edge. Or using Canvas resize, and copying the largest size (depends if image is portrait or landscape) and putting that into the smaller size. Then using flood fill to colour the transparent bars that are created.

Before ->

Non square image

After ->

Square Image

So how can I automate this process? Seems like there are human elements in my process that I can't automate and I guess there must be a way. I have the latest photoshop (also Lightroom if it can do it?).

4
  • Why arent you using imagemagick for this? No there is no human intervention needed.
    – joojaa
    Dec 18, 2021 at 13:33
  • 1
    Hi. Welcome to GDSE. Are all the images the exact same dimensions to begin with? If so, it could be done with an Action, and File > Automate > Batch.
    – Billy Kerr
    Dec 18, 2021 at 13:37
  • Thanks @joojaa I've never heard of imagemagick. I'll check it out.
    – delp
    Dec 19, 2021 at 13:38
  • @BillyKerr nope they are all different. landscape/portrait and a range of ratios.
    – delp
    Dec 19, 2021 at 13:38

1 Answer 1

2

Assuming your images are flattened, you can record an action like this:

  • Right-click the Background layer and select Duplicate Layer.

  • Double-click the Background layer to unlock it and select it.

  • Press Ctrl /Cmd + T to start transforming the selected layer. Hold down Shift, rotate the layer 90 degrees and press Enter to commit the transformation.

  • Perform Image > Reveal All to make the canvas a square.

  • Press D to reset the background and foreground colors.

  • Press Alt + Backspace to fill the selected layer with black.

  • Perform Layer > Flatten Image to flatten the image.

8
  • That's a clever trick! +1!!!!!
    – Billy Kerr
    Dec 19, 2021 at 13:40
  • Wow - that's some magic knowledge right there!! Awesome and perfectly scriptable.
    – delp
    Dec 19, 2021 at 13:41
  • @delp - but you don't need to script this. The Action alone would suffice. Just apply it using File > Automate > Batch.
    – Billy Kerr
    Dec 19, 2021 at 13:43
  • @BillyKerr Yeah that's what I'm meaning. Record the action then can apply that to every image. I was thinking of it like a script, but I think photoshop calls them actions. Just bad terminology from me.
    – delp
    Dec 19, 2021 at 13:45
  • 1
    @delp - yeah, Photoshop has Actions, but you can also use scripts. Actions are like recording a macro. Scripts have to be manually programmed using JavaScript, VB Script, AppleScript etc,
    – Billy Kerr
    Dec 19, 2021 at 13:55

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.