Tue Nov 29, 2011 4:17 pm
I have a script that relies on an image being in indexed color mode at onset, switches to rgb (so the image can be scaled w interpolation) and then switches back to indexed.
If I use the script on an image that is in RGB mode it chokes and dies.
Is there a way to determine what mode an image is in so that I can handle these images accordingly?
Or is there a way to override the error message such that the rest of the script will execute?
Or maybe I'm going about doing this all wrong as it is and you know of a better way.
Thanks in advance.
Tue Nov 29, 2011 4:47 pm
If you are authoring the script, you could just convert the image to the correct mode (if already that mode, it won't matter) in the script. Now I have to add, I'm not a script writer so don't ask me how. If you are like me, an end user, you can always check to see by doing Image>Mode to see.
Tue Nov 29, 2011 5:15 pm
That is what I was looking for! I kept searching in the PDB using the wrong words so never found this function. Thanks.
I wanted an automated way to handle the file type. So Lylejk's suggestion wasn't exactly what I was looking for.
Thanks for everyone's input!
Wed Nov 30, 2011 10:17 am
FYI - when you register a script, the 7th parameter is type of image you want it to work on...
If you leave it blank "" it works with any kind.
If you only want users to call the script on indexed images, set it to "INDEXED" and it will be greyed out in the menu if the image is RGB greyscale.
Other options are RGB, RGBA, RGB*, GRAY, GRAYA, GRAY* which you can use for any combination:
"RGB GRAY* INDEXED" would enable the menu items for image/layers RGB (without alpha), greyscale (alpha or not) or indexed.
-Rob A>
Wed Nov 30, 2011 10:52 am
RobA wrote:FYI - when you register a script, the 7th parameter is type of image you want it to work on...
If you leave it blank "" it works with any kind.
To clarify, if you leave it blank then it works on any kind of image
or no image at all -- for example, if you are writing a script that generates a new image from scratch and does not care whether an image is already open.
To specify that an image must be open -- but without caring what kind of image -- use "*" for the constraint parameter.