Post Reply 

Convert to RGB then to Indexed Color

Jul 27, 2012, 19:12
Post: #1
Convert to RGB then to Indexed Color
I am trying to save myself a lot of extra clicking as I have to modify several hundred images. In order to do what I need to, I have to convert my image to RGB and then convert it to Indexed color.

I am trying to save myself some clicks by making a script-fu script to do the work. Regretfully I have little understanding of the script-fu language and the script errors telling me there are not enough elements to register it. Here is what I have:

(define (ReindexColors)
(gimp-image-convert-rgb image)
(gimp-image-convert-indexed image dither-type palette-type num-cols alpha-dither remove-unused palette)
( script-fu-register

Can anyone assist me?
Find all posts by this user
Quote this message in a reply
Jul 27, 2012, 20:06 (This post was last modified: Jul 27, 2012 20:07 by ofnuts.)
Post: #2
RE: Convert to RGB then to Indexed Color
Script-fu is actually Scheme which is a Lisp derivative.

Many people (including me) find it a lot easier to use Python for scripts. it usually results into shorter and more readable code.

I'm don't know much of script-fu, but there are numerous problems with you existing code, even outside of the registration: you don' t define the script parameters, and most of your variables aren't initialized.

Your best bet to make a working script is to grab a script elsewhere and modify it step by step until it does what you want (look into the "scripts" (for script-fu) or plugins (for python-fu) directory of your Gimp installation tree for existing stuff that can be used as examples. The Gimp registry is a also great source of scripts.

This said, for relatively simple processing like this, and if you have to run on several images, you should have a look at ImageMagick's convert command, it will likely be much easier to setup and to run. See in particular

Now answering your questions on
Visit this user's website Find all posts by this user
Quote this message in a reply
Jul 28, 2012, 17:51
Post: #3
RE: Convert to RGB then to Indexed Color
Thanks for your reply. I ended up finishing the work off by hand. I would still like to learn more about the proper file structure for a script-fu script. Can anyone point me to a reference?

Looking at examples without an explanation does little to help me understand the elements needed in the file.
Find all posts by this user
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Color menuitems in script or plugin Barbie 4 521 Sep 29, 2014 09:51
Last Post: paynekj
  Script fu and Color to alpha john 4 517 Sep 20, 2014 08:46
Last Post: rich2005
  Easy Color gfb 2 563 May 4, 2014 02:05
Last Post: gfb
  'do not write color space information' in script-fu eab 0 520 Aug 13, 2013 10:03
Last Post: eab
  Color Balance Midi Lessbones 3 1,072 Dec 24, 2012 20:25
Last Post: Lessbones

Forum Jump:

GIMP ForumPortalArchiveContactTermsRSS