Copy link to clipboard
Copied
Need to add this to an action, rather than making all images square manually before batching them all.
- All 500+ images are various sizes both portait, landscape and possibly square already.
- They are all cropped tightly around the product with a white background.
So currently: I just use canvas size, anchor to the centre and change the smallest pixel dimension to make it square, so none of the product is cropped.
Any ideas?
I couldn't get JJMack's aspect ratio script to help me.
Automate -> Fit Image will take it to 1000 pixels but still won't be square.
EDIT: Oh my. I just found this, looks like it'll do the job. Will test some more in the morning.
var savedRuler= app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var w = app.activeDocument.width;
var h = app.activeDocument.height;
if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);
if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);
//if w==h already square
app.preferences.rulerUnits = savedRuler;
Near the top where you set the ruler add these lines.
var startColor = app.backgroundColor;
if(startColor.rgb.hexValue != 'FFFFFF'){
var white = new SolidColor();
white.rgb.hexValue = 'FFFFFF';
app.backgroundColor = white;
}
and at the bottom add this line
if(white != undefined) app.backgroundColor = startColor;
Copy link to clipboard
Copied
! would add is a check of the background color and set it to white if needed.
Copy link to clipboard
Copied
Ahh yep ok. How do I do that?
Copy link to clipboard
Copied
Near the top where you set the ruler add these lines.
var startColor = app.backgroundColor;
if(startColor.rgb.hexValue != 'FFFFFF'){
var white = new SolidColor();
white.rgb.hexValue = 'FFFFFF';
app.backgroundColor = white;
}
and at the bottom add this line
if(white != undefined) app.backgroundColor = startColor;
Copy link to clipboard
Copied
Brilliant, thank you Michael.
Copy link to clipboard
Copied
I have a need for this script as well. Is this the entire script? If not, can you post the complete script?
I just need to increase either the canvas width (as white area for the added width/height) or the canvas height to match the longest side of an image so they they are perfectly square. No cropping or reduction in image sizes. These are product images on white background.
Is this the full script?
var startColor = app.backgroundColor;
if(startColor.rgb.hexValue != 'FFFFFF'){
var white = new SolidColor();
white.rgb.hexValue = 'FFFFFF';
app.backgroundColor = white;
}
var savedRuler= app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var w = app.activeDocument.width;
var h = app.activeDocument.height;
if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);
if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);
//if w==h already square
app.preferences.rulerUnits = savedRuler;
if(white != undefined) app.backgroundColor = startColor;
So I went ahead and tried the script I posted previously, and it works great for my needs. It even works great saved as a step in an action. However, when I try to batch run this action on a group of images in a folder (from bridge), the process is interrupted for every single image with the following dialogue box. I'm actually not sure what to put in here manually anyway, but the main question is "why" is this popping up when I run as batch, but not when I open an image and then run the action? How can I suppress the dialogue and have it work in batch mode just like when I manually run the action?
Hopefully this will help someone down the road. Here is my final script that works in batch mode from bridge:
var startColor = app.backgroundColor;
if(startColor.rgb.hexValue != 'FFFFFF'){
var white = new SolidColor();
white.rgb.hexValue = 'FFFFFF';
app.backgroundColor = white;
}
var savedRuler= app.preferences.rulerUnits;
app.displayDialogs = DialogModes.NO;
app.preferences.rulerUnits = Units.PIXELS;
var w = app.activeDocument.width;
var h = app.activeDocument.height;
if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);
if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);
//if w==h already square
app.preferences.rulerUnits = savedRuler;
if(white != undefined) app.backgroundColor = startColor;
Copy link to clipboard
Copied
I have the same problem, I have 1000's of product images with white backgrounds, both portrait and square. But as I scroll through the comment I feel out of my depth ... I'm a graphic designer, not a 'computer guy'. So, is there an action I can create or a droplet? I have been able to get to a point where I can do my landscpe images and portrait images by MANUALLY sorting them, but I cant Action/Droplet them all at once which would be a huge time saver.
It would be great if the Folks at Adobe would create an action that 'turns images into uniform size, square, 4:3 ... whatever!
HELP!
Copy link to clipboard
Copied
You need to crop your Images square then you can resize the square document canvas to canvas size you want. The Plug-in script in my crafting Action Package AspectRatioSelection can be use in and actions to set a centered square selection for you image document that you can Crop to. Any Aspect Ration can be recorded into your Action. The Aspect ratio will be set for your the document being edited. If you record 4 3 portrait will have a 3:4 Aspect Ratio selection set and landscape and square images will have a 4:3 Aspect Ratio selection set