0 Replies Latest reply on Dec 14, 2015 7:00 AM by DBLjan

    listbox image: scale instead of crop?

    DBLjan Level 2

      Hi there scripting aces, im working on an export-script. After export I want to throw a snazzy window with the exported results. Peters ScriptUI comes along with an example to scale images instead of cropping, but that doesnt work with images in a listbox, or/and i'm not able to read Marc Autret fancy optimzed JS to make images scale, …since Im a newbee at JS.


      Can somebody help me out, get this prototype-thing to work/scale?

      Here is my image, its cropped in the dialog :-/


      500x500px.jpgBildschirmfoto 2015-12-14 um 15.59.17.png


      function MyWindow(){
      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]),
      // Resize proportionally:
      wh = [k*wh[0],k*wh[1]];
      // Center:
      xy = [ (WH[0]-wh[0])/2, (WH[1]-wh[1])/2 ];
      WH = wh = xy = null;
      // here comes my stuff
      var w = new Window ("dialog", "Exportresults");
      var myList = w.add ("listbox", undefined, "", {multiselect: false, numberOfColumns: 3, showHeaders: true, columnTitles: ["Preview", "Name", "LfnNr"], columnWidths: [55,390,80]});
      for (var k = 0; k < 5; k++) 
      {  with (myList.add ("item", "here comes an image"))
      {  var FileTemp = File("~/Desktop/500x500px.jpg");
         myList.items[k].image = File(FileTemp);
         subItems[1].text = ""+k;
         subItems[0].text = FileTemp.displayName;
      myList.bounds = [0,0,610,260]
      myList.itemSize= [590,50];
      var buttons = w.add ("group")
      var OKbutt = buttons.add ("button", undefined, "OK", {name: "ok"});
      OKbutt.onClick = function () {w.close();}
      w.show ();