Copy link to clipboard
Copied
I have a problem with image preview
use mac with high sierra
with photoshop cc2014 everything ok works properly
instead in photoshop 2018 I get out error
where am I wrong?
// script
function main(){
inputFolder = Folder.selectDialog("SELECT FOLDER IMAGE:");
var fileList = inputFolder.getFiles(/\.(jpg|png)$/i);
Image.prototype.onDraw = function(){
// "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", "PREVIEW");
win.pnl1 = win.add('panel', undefined, undefined, {borderStyle:'black'});
win.pnl1.preferredSize=[400,400];
win.Im1 = win.pnl1.add ("image", undefined,fileList[0]);
win.Im1.size = [400,400];
win.pnl2 = win.add('panel', undefined, undefined, {borderStyle:'black'});
win.pnl2.orientation = "row";
win.pnl2.bu2 = win.pnl2.add('button',[110,10,200,30],'BACK');
win.pnl2.bu1 = win.pnl2.add('button',[10,10,100,30],'NEXT');
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();
Copy link to clipboard
Copied
I confirm something is wrong, as my code worked in CS6 (and some later version), but now ran in CC 2018 fails after selecting folder with images to preview in mini-browser: https://www.ps-scripts.com/viewtopic.php?f=77&t=40429
Copy link to clipboard
Copied
Your first code works well only with .png files
instead if sono.jpg comes out error
// script
// it open little image browser within Photoshop
function brwsr() {
u = undefined, Image.prototype.onDraw = function() {
WH = [(k = Math.min(wh[0] / (WH = this.image.size)[0], wh[1] / WH[1])) * 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=(upr=(win=new Window('dialog', 'PREVIEW')).add('panel', u, u, {borderStyle:'black'})).preferredSize=[400, 400];
(img = upr.add('image', u, fL[0])).size = wh; (btm = win.add('panel', u, u, {borderStyle:'black'})).orientation='row'
p = 0; function IF(v) {return v ? 'if (p) img.image = fL[--p]' : 'if (fL[p + 1]) img.image = fL[++p]'}
obj = {CLOSE: 'win.close()', BACK: IF(true), NEXT: IF(false), OPEN: 'open(File(fL
)), refresh()'}
for(i in obj) eval("btm.add('button', [107, 10, 200, 33], i).onClick = function() {" + obj +"}"); win.show()
}
if ((fL = Folder.selectDialog('SELECT IMAGE\'S FOLDER:').getFiles(/\.(jpg|png)$/i)).length) brwsr()
Copy link to clipboard
Copied
In my case function I made:
function XY(v) {return XMP.getProperty(XMPConst.NS_EXIF, 'Pixel' + v + 'Dimension')}
doesn't give expected result, so probably problem is earlier ie:
Folder.selectDialog('SELECT IMAGE\'S FOLDER:').getFiles(/\.jpg$/i).length
In ExtendScript Toolkit and earlier Photoshops it opens small files/folders browser while in CC 2018 entire screen Windows browser. I'm not sure it's a reason it can't see images, however when you test it returns .jpg files length in chosen folder. For now I have no time to find a reason... (regarding that code that has two versions read description - later I'll see what to do).
Copy link to clipboard
Copied
I tried but I get an error
Copy link to clipboard
Copied
Maybe I do not understand something, but it always worked only with PNG fotmat. (At me at least).
The documentation says the same thing.
Copy link to clipboard
Copied
In this case it's about 'preview', not 'iconbutton'. At end of following topic you find code using 'iconbutton', but it's something different than in case of this topic, however works together with .jpg and .png files as well: https://www.ps-scripts.com/viewtopic.php?f=67&t=24398#p152646
Copy link to clipboard
Copied
What is this "preview"?
Copy link to clipboard
Copied
Run 'Version II' script in CS6 and you will see however I'm going to find information in decumentation for you as well:
https://www.ps-scripts.com/viewtopic.php?f=77&t=40429#p169072
Copy link to clipboard
Copied
r-bin
I need to show preview of jpg files
do you think it's possible to do it?
Copy link to clipboard
Copied
I never did it. But Kukurykus claims that it is possible. I'll look somehow )
Copy link to clipboard
Copied
I'm sorry I did mistake. I did not mean 'preview', but 'image' ('preview' was name for 'dialog' in that code - I'm in rush )
In case of 'image' documentation states that must be 'PNG', so like for 'iconbutton', but that's not true for both, I used jpg's:
On pages 68-69 (71-72) you will find that author of unofficial documentation also used .jpg: https://indd.adobe.com/view/a0207571-ff5b-4bbf-a540-07079bd21d75
Copy link to clipboard
Copied
Yes, it really works in CS6.
And I did not know!
Once again, I'm convinced that the CC2018 is worse in terms of scripts than CS6.
UPD. I do not know when they did it, but at least in CS2-CS3 it does not work.
Copy link to clipboard
Copied
I'm happy first time you could get to know something from me, not only that it's me learning from you
Copy link to clipboard
Copied
Photoshop cc2018 and the most total failure for scripts
I'm having a lot of problems
in photoshop cc2014 the scripts were fine
now and a drama.
Copy link to clipboard
Copied
I didn't read it yet, just title, but you're not the one: Why is Photoshop such a crap?! bugs are part of Photoshop, buying this product you pay also for them. A solution from some Adobe employee about 'Device Preview' I heard is to use older versions for them and other stuff that is missing or work uncorrectly, while new ones for features there weren't available before. However it sounds we must deal with...
Copy link to clipboard
Copied
Works for me with CS3, CS5 and CS6 (Windows) I don't have CS4 installed.
Copy link to clipboard
Copied
I guess it only doesn't work in CS2 and prior vers. as ScriptUI first time came with CS3. Question is which CC broke 'image'.
Copy link to clipboard
Copied
Yah!
Copy link to clipboard
Copied
up to cc2014 I had no problems with cc2018 it does not work In your opinion, can you solve it?
Copy link to clipboard
Copied
If you had a Windows, I would suggest a solution.
There is a wonderful utility nircmd. NirCmd - Windows command line tool
It perfectly converts from one format to another. In a script, it's easy to make a call to convect the current file into a temporary PNG. Then read this file in a string and substitute it for the argument "icon"
Copy link to clipboard
Copied
So 'image' isn't part of ScriptUI that gave more options? I remember I couldn't do many User Interference things in CS2 like in later versions, and assumed that was one of them, though never tried.
Copy link to clipboard
Copied
// off topic
Everything worked fine there (with the exception of selection.bounds, but it's solvable). This is the best photoshop before CS6 and after v7.
IMHO )