It is currently Tue Jul 02, 2024 1:34 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Is there a way to determine type of image mode (rgb/indexed/greyscale)
PostPosted: Tue Nov 29, 2011 4:17 pm  (#1) 
Offline
GimpChat Member

Joined: Nov 07, 2011
Posts: 6
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.


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Is there a way to determine type of image mode (rgb/indexed/greysc
PostPosted: Tue Nov 29, 2011 4:47 pm  (#2) 
Offline
GimpChat Member
User avatar

Joined: Sep 24, 2010
Posts: 12531
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 3593 times ]

_________________
Lyle

Psalm 109:8

Image
Top
 Post subject: Re: Is there a way to determine type of image mode (rgb/indexed/greysc
PostPosted: Tue Nov 29, 2011 5:00 pm  (#3) 
Offline
Script Coder
User avatar

Joined: Jun 22, 2010
Posts: 1171
Location: Here and there
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


Top
 Post subject: Re: Is there a way to determine type of image mode (rgb/indexed/greysc
PostPosted: Tue Nov 29, 2011 5:09 pm  (#4) 
Offline
GimpChat Founder
User avatar

Joined: May 22, 2008
Posts: 5242
Location: Gimpville
gimp-image-base-type

Opps :oops: :ninja

_________________
“If you reach for the stars, you just might land on a decently sized hill.” - Stuart Hill


Top
 Post subject: Re: Is there a way to determine type of image mode (rgb/indexed/greysc
PostPosted: Tue Nov 29, 2011 5:15 pm  (#5) 
Offline
GimpChat Member

Joined: Nov 07, 2011
Posts: 6
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!


Top
 Post subject: Re: Is there a way to determine type of image mode (rgb/indexed/greysc
PostPosted: Wed Nov 30, 2011 10:17 am  (#6) 
Offline
Script Coder
User avatar

Joined: Jul 14, 2010
Posts: 697
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>

_________________
Image
Fantasy Cartography and Mapping by RobA


Top
 Post subject: Re: Is there a way to determine type of image mode (rgb/indexed/greysc
PostPosted: Wed Nov 30, 2011 10:52 am  (#7) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
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.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) "Indexed" in Image->Mode is disabled.

8

No new posts Attachment(s) 'Equalize' and 'White Balance' makes image greyscale

3

No new posts Attachment(s) exporting 256-color indexed png & gif missing transparency

9

No new posts wrong parameter type in pdb.plug_in_cubism

9

No new posts Can't open files 'Unknown file type'

7



* Login  



Powered by phpBB3 © phpBB Group