#Photoshop script

1 messages · Page 1 of 1 (latest)

vestal nexus
#

I am trying to resize an image to fit on my dialog

rose bloom
safe orchid
vestal nexus
# rose bloom I need more information to know if I can help.

function main() {
inputFolder = Folder.selectDialog("Please select the folder with Files to process");
var fileList = inputFolder.getFiles(/.(png|png)$/i);

Image.prototype.onDraw = function () { // written by Marc Autret
// "this" is the container; "this.image" is the graphic
if (!this.image) return;
var WH = this.size,
wh = this.image.size,
k = Math.min(WH[0] / wh[0], WH[1] / wh[1]),
xy;
// Resize proportionally:
wh = [k * wh[0], k * wh[1]];
// Center:
xy = [(WH[0] - wh[0]) / 2, (WH[1] - wh[1]) / 2];
this.graphics.drawImage(this.image, xy[0], xy[1], wh[0], wh[1]);

  WH = wh = xy = null;

};

var win = new Window("dialog", "Image test");
win.pnl1 = win.add('panel', undefined, undefined, {
borderStyle: 'black'
});
win.pnl1.preferredSize = [200, 200];
win.Im1 = win.pnl1.add("image", undefined);
var imageFile = new File(fileList[0]);
win.Im1.image = imageFile;
win.Im1.size = [180, 180];
win.pnl2 = win.add('panel', undefined, undefined, {
borderStyle: 'black'
});
win.pnl2.bu1 = win.pnl2.add('button', undefined, 'Next');
win.pnl2.bu2 = win.pnl2.add('button', undefined, 'Previous');
win.grp100 = win.add('group');
win.grp100.bu1 = win.grp100.add('button', undefined, 'Cancel');
var PIC = 0;
win.pnl2.bu1.onClick = function () {
//Next picture
if (PIC == fileList.length - 1) return;
PIC++;
win.Im1.image = File(fileList[PIC]);
};
win.pnl2.bu2.onClick = function ()
//Previous
{
if (PIC == 0) return;
PIC--;
win.Im1.image = fileList[PIC];
}
win.show();
}
main();

safe orchid
#

Ok, I’m not a coder, but I think you should explain what you get and what you want from there.

vestal nexus
#

it does show but i cant resize it