Skip to main content
Known Participant
March 12, 2011
Answered

Display thumbnail of PSD on ScriptUI dialog

  • March 12, 2011
  • 1 reply
  • 8665 views

I'm wanting to display a thumbnail sized jpeg or png image representation of a high resolution PSD on my ScriptUI dialog, and without having the PSD open and active. Any advice or suggestions to get me started in the right direction is much appreciated.

JJ

This topic has been closed for replies.
Correct answer Paul Riggott

Paul, have you worked out a method for looping thru an array of images previews within a dialog? I must have spent a whole day the other week trying this… All I was trying was to have two buttons 'previous' & 'next'… But I'll be shot if I could work this out this ScriptUI stuff is still very new to me… I can remove an image from its parent window container but can I put a replacement back… nope…


Yes here is an example, BUT it will not work with Photoshop CS5 (Yet another bug!) works with Photoshop CS3 and CS4

It will work with Bridge and Illustrator CS5 though.



function main(){
inputFolder = Folder.selectDialog("Please select the folder with Files to process");
var fileList = inputFolder.getFiles(/\.(jpg|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,fileList[0]);
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 = fileList[PIC];
    }
win.pnl2.bu2.onClick=function(){
//Previous
if(PIC == 0 ) return;
PIC--;
win.Im1.image = fileList[PIC];
    }
win.show();
}
main();

1 reply

Muppet_Mark-QAl63s
Inspiring
March 12, 2011

What OS are you on?

JJ_FulksAuthor
Known Participant
March 12, 2011

Windows XP Pro 32-bit

Muppet_Mark-QAl63s
Inspiring
March 12, 2011

Sorry… my suggestion would have been to use SIPS on the mac. Bridge can create new bitmaps from thumbnails… I have not needed to use this myself but it 'might' be a possible route on Windows…? Paul has used this before so maybe he would know…?