# Batch convert pictures to 4:3 adding black horizontal bands



## Nostromozar (Jun 25, 2008)

First of all... hello everyone! this is my first post.

I need a program to do the following thing:

I have thousands of pictures, some of them have 4:3 aspect ratio, others have 3:2 aspect ratio, and a few of them non standar aspect ratios.

I need all of them to be the same aspect ratio (4:3), adding horizontal black bands if needed but never cropping the picture.

Can this be done? I can't find this option in the programs I use.

Thanks!


----------



## Chris Stegner (Jun 25, 2008)

I use Photoshop and I can create an "Action" to apply the same steps to multiple photos. If you don't have PS then maybe a friend would let you use their machine to do it. I use it all the time. You basically tell it to "Record" your steps, then you you direct it to a folder of images and it will do the same to all the images in the folder.


----------



## Nostromozar (Jun 26, 2008)

Thanks Chris, I use Photoshop CS3, but this is too complicated for an Action.

I finally managed to do it, but using Photoshop ExtendScript. 

I copy the script here to change to 4:3 in case somebody needs it, you only need to save it with jsx extension in a text file.

app.preferences.rulerUnits = Units.PIXELS
app.preferences.typeUnits = TypeUnits.PIXELS
app.backgroundColor.rgb.red=0;
app.backgroundColor.rgb.green=0;
app.backgroundColor.rgb.blue=0;


var miImagen = app.activeDocument
var x = miImagen.width
var y = miImagen.height
var ratio;
var xx = x;
var yy = y;

if (x>=y) {
            ratio=(x/y);
            if (ratio!=(4/3)) {
                    if (ratio>(4/3)) {
                            xx=x;
                            yy=(x*3/4);
                    } else {
                            yy=y;
                            xx=(y*4/3);
                    }
            }
} else {
            ratio=(y/x);
            if (ratio!=(4/3)) {
                    if (ratio>(4/3)) {
                        yy=y;
                        xx=(y*3/4);
                    } else {
                        xx=x;
                        yy=(x*4/3);
                    }
            }        
}

miImagen.resizeCanvas(xx,yy)


----------



## Garbz (Jun 26, 2008)

Nice work. Pity the forum ruins the formatting. Incidently I was going to go ahead and recommend GIMP not knowing you had photoshop since this is hardly the type of thing you would want to spend money for but decided against it when I realised you had to code action scripts in GIMP. I thought it would be too difficult :lol

Just goes to show you never know.


----------

