• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Resize Canvas to 800x800 and Transform Rectangular Image to fit in those bounds

New Here ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

I keep trying to do this, using this script batch odd dimension images to square  for reference and I can't manage to get it...

What I want to do--for instance--is take a 1000x800 image, resize the canvas to 800x800, and then transform the image so that it is centered. So it becomes an 800x640 image and the 640 is centered.

It seems like this is a PERFECT task for scripting but I can't manage it right now. Can anyone help me out? Thanks so much in advance!

TOPICS
Actions and scripting

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Apr 13, 2017 Apr 13, 2017

Copy link to clipboard

Copied

// 2017, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

var myDocument = app.activeDocument;

var originalRulerUnits = preferences.rulerUnits;

preferences.rulerUnits = Units.PIXELS;

var theTarget = 800;

// get longer side;

var theFactor = theTarget / getTheLonger(Number(myDocument.width), Number(myDocument.height));

// resize;

myDocument.resizeImage (myDocument.width * theFactor, myDocument.height * theFactor, myDocument.resolution, ResampleMethod.BICUBICAUTOMATIC);

myDocument.resizeCanvas (theTarget, theTarget);

// reset;

preferences.rulerUnits = originalRulerUnits;

}

else {};

function getTheLonger(a,b) {

  if (a >= b) {

  var x = a}

  else {

  var x = b};

  return x;

  };

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Apr 14, 2017 Apr 14, 2017

Copy link to clipboard

Copied

Menu > File > Automate > Fit Image...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 14, 2017 Apr 14, 2017

Copy link to clipboard

Copied

But to get a final square one would need to add a Canvas Size operation (in an Action for example).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 14, 2017 Apr 14, 2017

Copy link to clipboard

Copied

LATEST

A simple action that you can batch will do it.  The tricky part is recording the Canvas size step so that 800 width and height are both recorded. Record

Step 1 Flatten (so canvas added will be filled with the background color)

Step 2 File>Automate>Fit Image... width and height set 800px. (Images aspect will be maintained so there no distortion The resulting image width or height may be less than 800 px.

Step 3 Canvas size 800px wide 800 px hight, (You must force this step to recorde correctly.) Stop recording before recording the Canvas Size step. Crop the fitted  work image to a smaller size so both the width and height are less the 800px.  Then click the record icon and record the Canvas size step 800px by 800ps leave the anchor point in the center and select the background color you want.

Stop recording the action is complete.

Capture.jpg

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines