Skip to main content
Participating Frequently
May 5, 2014
Answered

Bridge UI not displaying images, OK in ESTK. Why?

  • May 5, 2014
  • 2 replies
  • 983 views

Can anyone shed some light at a following problem.

I have a UI that will be displayed in Bridge, part of it is a file preview of an image. Everything works well when I run it in ESTK, but when Bridge is targeted, I get a blank frame.

Yes all my images are jpg.

Code is as simple as:

var myNewFile = "~/Desktop/temp/mytestfile.jpg"; 

var w = new Window ("palette", "Thumbnail");

var thumbnail = w.add ("image",undefined, myNewFile);

w.show();



This topic has been closed for replies.
Correct answer Pedro Cortez Marques

Yes its true that there are bugs from Bridge CS6 (and still on CC) using its scriptUI.

The framework name used on Bridge is 'Mondo'. On Photoshop CS6 is 'flex' and on ESTK is 'Win32'.

I really manage to create an work around on Bridge to get the image appear using an icon button and script UI (its your choice to use it as button or not...).

You can add this image to:

  • an UI panel;
  • to the navBar (fileSystem);
  • to your TabbedPalette created using SDK CS6

// create a panel here:

var tbPanel = (...)

//

var fileFoto = File(Folder.desktop + '/temp/mytestfile.jpg');

if (fileFoto.exists) {

     var myImg = ScriptUI.newImage(fileFoto);

     tbPanel.photo = tbPanel.add('iconbutton', [0,0, undefined,undefined], myImg, {style:"toolbutton"});

     tbPanel.photo.size = [44,50]; // this should be the size of the image. If it doesn't exists it will add space around the image

     tbPanel.photo.onDraw = function () { // this is necessary, but if you use it many times, put this function outside and call it when needed.

          with( this ) {

               graphics.drawOSControl();

               graphics.drawImage (image, 0, 0, image.size[0], image.size[1]);

          }

     }

}

Hope it helps.

2 replies

Pedro Cortez Marques
Pedro Cortez MarquesCorrect answer
Legend
May 6, 2014

Yes its true that there are bugs from Bridge CS6 (and still on CC) using its scriptUI.

The framework name used on Bridge is 'Mondo'. On Photoshop CS6 is 'flex' and on ESTK is 'Win32'.

I really manage to create an work around on Bridge to get the image appear using an icon button and script UI (its your choice to use it as button or not...).

You can add this image to:

  • an UI panel;
  • to the navBar (fileSystem);
  • to your TabbedPalette created using SDK CS6

// create a panel here:

var tbPanel = (...)

//

var fileFoto = File(Folder.desktop + '/temp/mytestfile.jpg');

if (fileFoto.exists) {

     var myImg = ScriptUI.newImage(fileFoto);

     tbPanel.photo = tbPanel.add('iconbutton', [0,0, undefined,undefined], myImg, {style:"toolbutton"});

     tbPanel.photo.size = [44,50]; // this should be the size of the image. If it doesn't exists it will add space around the image

     tbPanel.photo.onDraw = function () { // this is necessary, but if you use it many times, put this function outside and call it when needed.

          with( this ) {

               graphics.drawOSControl();

               graphics.drawImage (image, 0, 0, image.size[0], image.size[1]);

          }

     }

}

Hope it helps.

Matt StecAuthor
Participating Frequently
May 7, 2014

This seems to be working fine Pedro, thanks, now I just have to figure out how to scale the image so it doesn't crop it, but at least the image is being displayed. Thanks very much.

Matt StecAuthor
Participating Frequently
May 7, 2014

OK, this worked for me if anyone is looking for the same:

var w = new Window ("palette", "Thumbnail");

var fileFoto = File("~/Desktop/P1010627.JPG");

if (fileFoto.exists) {

  var myImg = ScriptUI.newImage(fileFoto);

  image = w.add('iconbutton', [0,0, 400,400], myImg, {style:"toolbutton"}); //400 x400 being the size of the window

  image.onDraw = function () {

  with( this ) {

  if( !this.image ) return;

  var WH = this.size,

  wh = this.image.size,

  k = Math.min(WH[0]/wh[0], WH[1]/wh[1]),xy;

  wh = [k*wh[0],k*wh[1]];

  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;

  graphics.drawOSControl();

  }

  }

}

w.show();

not sure what graphics.drawOSControl(); does, seems to be working without it, Pedro?

Inspiring
May 5, 2014

Sounds as if you are using CS6 or CC, bugs in UI programming were reported before CS6 was released but sadly they were never fixed and there were numerous bugs!

CS5 is the last good version, anything newer and you are going to encounter major problems.

Matt StecAuthor
Participating Frequently
May 5, 2014

I'm using CC. Thanks for your answer, not good news tho.