GIMP Chat
http://gimpchat.com/

Is there a way to determine type of image mode (rgb/indexed/greyscale)
http://gimpchat.com/viewtopic.php?f=9&t=3197
Page 1 of 1

Author:  InkyDinky [ Tue Nov 29, 2011 4:17 pm ]
Post subject:  Is there a way to determine type of image mode (rgb/indexed/greyscale)

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.

Author:  lylejk [ Tue Nov 29, 2011 4:47 pm ]
Post subject:  Re: Is there a way to determine type of image mode (rgb/indexed/greysc

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

Attachments:
modecheck.png
modecheck.png [ 33.45 KiB | Viewed 3605 times ]

Author:  paynekj [ Tue Nov 29, 2011 5:00 pm ]
Post subject:  Re: Is there a way to determine type of image mode (rgb/indexed/greysc

gimp-image-base-type will tell you what type of image you have, but if you want to only be able to run the script on a particular image type, then you should specify the type when registering it: http://docs.gimp.org/en/gimp-using-scri ... cript.html

That said, I think Lylejk's suggestion to set the image type to what you need it to be is a good one.

gimp-image-convert-indexed and gimp-image-convert-rgb would help here.

Note: I found all of these functions using the Procedure Browser:- Help >> Procedure Browser

Kevin

Author:  GnuTux [ Tue Nov 29, 2011 5:09 pm ]
Post subject:  Re: Is there a way to determine type of image mode (rgb/indexed/greysc

gimp-image-base-type

Opps :oops: :ninja

Author:  InkyDinky [ Tue Nov 29, 2011 5:15 pm ]
Post subject:  Re: Is there a way to determine type of image mode (rgb/indexed/greysc

paynekj wrote:
gimp-image-base-type will tell you what type of image you have, but if you want to only be able to run the script on a particular image type, then you should specify the type when registering it: http://docs.gimp.org/en/gimp-using-scri ... cript.html


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!

Author:  RobA [ Wed Nov 30, 2011 10:17 am ]
Post subject:  Re: Is there a way to determine type of image mode (rgb/indexed/greysc

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>

Author:  saulgoode [ Wed Nov 30, 2011 10:52 am ]
Post subject:  Re: Is there a way to determine type of image mode (rgb/indexed/greysc

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.

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/