• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

problem image preview

Advocate ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

I have a problem with image preview

use mac with high sierra

with photoshop cc2014 everything ok works properly

Schermata 2018-03-09 alle 09.53.07.png

instead in photoshop 2018 I get out error

Schermata 2018-03-09 alle 10.06.35.png

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(); 

TOPICS
Actions and scripting

Views

1.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
LEGEND ,
Mar 09, 2018 Mar 09, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

Your first code works well only with .png files

instead if sono.jpg comes out error

Schermata 2018-03-09 alle 10.47.25.png

// 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()

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 09, 2018 Mar 09, 2018

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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

I tried but I get an error

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 09, 2018 Mar 09, 2018

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.

zzzzzzzzz.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 09, 2018 Mar 09, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

What is this "preview"?

ccccc.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 09, 2018 Mar 09, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

r-bin

I need to show preview of jpg files

do you think it's possible to do it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 09, 2018 Mar 09, 2018

Copy link to clipboard

Copied

I never did it. But Kukurykus claims that it is possible. I'll look somehow )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 09, 2018 Mar 09, 2018

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:

Image.jpg

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 09, 2018 Mar 09, 2018

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 09, 2018 Mar 09, 2018

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 09, 2018 Mar 09, 2018

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 09, 2018 Mar 09, 2018

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Mar 10, 2018 Mar 10, 2018

Copy link to clipboard

Copied

Works for me with CS3, CS5 and CS6 (Windows) I don't have CS4 installed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 10, 2018 Mar 10, 2018

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'.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 10, 2018 Mar 10, 2018

Copy link to clipboard

Copied

Untitled-1.png

Untitled-2.png

Yah!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Mar 10, 2018 Mar 10, 2018

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 10, 2018 Mar 10, 2018

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"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 10, 2018 Mar 10, 2018

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 10, 2018 Mar 10, 2018

Copy link to clipboard

Copied

LATEST

// 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 )

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines