Reduce the number of colors on a selection
Hi Chris, thanks for the reply.
El dg 02 de 03 del 2008 a les 15:47 -0600, en/na Chris Mohler va
escriure:
Maybe this:
1. Copy your selection
2. Edit->Paste as New
3. Image->Mode->Indexed
4. Image->Mode-RGB
5. Select All
6. Copy
7. Paste back into original image
8 close the auxiliar image
9 confirm that I don't want to save...
To many steps, but it does just what I need, so here is a little script
implementing that, it appears at colors->index-selection:
;; Copyright 2008 by Pere Pujal i Carabantes
;; License GNU/GPL
;; Author Pere Pujal i Carabantes
(define (script-fu-index-selection
image
drawable
p-type
number-of-colors
palette
remove-unused
d-type
alpha-dither
)
(let*(
(dither-type (list-ref '(0 1 2 3) d-type))
(palette-type (list-ref '(0 2 3 4) p-type))
(indeximage)
)
(gimp-image-undo-group-start image)
(gimp-edit-copy drawable)
(set! indeximage (car (gimp-edit-paste-as-new)))
(gimp-image-convert-indexed indeximage dither-type palette-type
number-of-colors alpha-dither remove-unused palette )
(gimp-image-convert-rgb indeximage)
(gimp-selection-all indeximage)
(gimp-edit-copy (car (gimp-image-get-active-layer indeximage)))
(gimp-floating-sel-anchor(car (gimp-edit-paste drawable 0)))
(gimp-image-delete indeximage)
(gimp-displays-flush)
(gimp-image-undo-group-end image)
))
(script-fu-register
"script-fu-index-selection"
"/Colors/Index Selection"
"Reduces the colors on the current selection."
"Pere Pujal i Carabantes"
"Copyright 2008"
""
""
SF-IMAGE "Image" 0
SF-DRAWABLE "Drawable" 0
SF-OPTION "Palette Type" '("MAKE-PALETTE" "WEB-PALETTE" "MONO-PALETTE"
"CUSTOM-PALETTE")
SF-ADJUSTMENT "Number of Colors (ignored unless Palette
type=MAKE-PALETTE)" '(255 2 256 1 25 0 0)
SF-PALETTE "Palette" "Web"
SF-TOGGLE "Remove unused (ignored if Palette type=MAKE-PALETTE)" FALSE
SF-OPTION "Dither type" '("NO-DITHER" "Floid Steinberg" "Floid
Steinberg LowBleed" "FIXED")
SF-TOGGLE "Alpha Dither" FALSE
)
Hope this helps other people too.
Yours
Pere