How to add my image in dialog

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Tokis

How to add my image in dialog

Post by Tokis »

How I can add my image (not iconbutton) in dialog?
with imageDraw() ? Please help me with this.
Mike Hale

How to add my image in dialog

Post by Mike Hale »

I have never gotten drawImage() to work. No matter what I try it throws an error, 'Can not execute'.

So I just use the image control.

Code: Select allvar dlg = new Window( 'dialog', 'Image Example Script' );
dlg.image = dlg.add ('image' , undefined, new File('/c/t.png'), {name:'temp'});
dlg.show();
Scott Miles

How to add my image in dialog

Post by Scott Miles »

Thanks Mike,

It works great!

When I try to substitute a relative path for the absolute path, I get an "invalid image data" warning. The image name is "image.png" and it's in the same folder as the script.

Code: Select alldlg.image = dlg.add ('image' , undefined, new File('./image.png'), {name:'temp'});

What am I doing wrong?

TIA
Mike Hale

How to add my image in dialog

Post by Mike Hale »

I have not used relative paths when creating an image resource but I don't think that would work like that. How would the File object constructor know which path to use as the base path.

I use a absolute path to create the resource. If I need the script to be flexible I use one of the following ways to build the absolute path.

One of the Folder class properties like Folder.userData.

One of the Zstring for Photoshops paths like app.path + "/" + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts");

Or File($.fileName).parent to get the folder where the script is installed.
Scott Miles

How to add my image in dialog

Post by Scott Miles »

Thanks Mike,

File($.fileName).parent seems to be giving me what I want.
theiviaxx

How to add my image in dialog

Post by theiviaxx »

I have never gotten drawImage() to work. No matter what I try it throws an error, 'Can not execute'.

You have to call this method from an onDraw callback. having said that, i haven't actually got that to draw properly, though it doesn't throw any errors.

I'll just use the image control
Tokis

How to add my image in dialog

Post by Tokis »

Hi, guys!
Please help draw a image on the group. DrawImage() etc.. Maybe only this way help me with my UI

The purpose of this: put the photo as background under a number of other Controllers (horizontal lines - another toolbutton controls, each line - one control) and photo must be visible through. I need create something as guidelines, but in the Dialog. A few groups in the stack not help. Group can not be transparent and they overlap each other

DrawImage() - this method leaves the hope that all will be drawn correctly. But for me it is not clear how to implement it.

Help with examples, please!