Gimp script-fu gimp-drawable-set-pixel
What’s this all about?
GIMP is a great free photo editing program. Like photoshop etc.
Script-fu is the name of the scripts that run in GIMP.
Scripts are written in the Scheme Language.
The problem
OK, this can be quite frustrating… the gimp-drawable-set-pixel function doesn’t seem to update the image in gimp!
The solution
Here’s the function you have to call to make your changes show and the script to work:
http://www.spinics.net/lists/gimp/msg14385.html
Credit to Saul Goode and Sven Neumann.
Step #1: Create a new image with a white background (any size will do)
and zoom in to the upper left corner.
Step #2: Open the Script-fu console (Xtns->Script Fu->) and enter the following commands
(the number “1″ in the first line assumes the new image is the first one
created after opening the GIMP; substitute the appropriate image-IDnum
from the window’s titlebar if this is not the case):
(define image 1)
(define layer (car (gimp-image-get-active-layer image)))
(gimp-drawable-set-pixel layer 10 10 3 (cons-array 3 ‘byte))
Note that at this point, the pixel at location x=10, y=10 has “internally”
been painted BLACK (’cons-array’ initializes to [0,0,0]) but the display
has not been updated.
Step #3: Enter the following line in the console:
(gimp-displays-flush)
Note that the display is not updated — this is somewhat anomalous (but
then Script-fu is not often used to paint on a pixel-by-pixel basis).
Step #4: The main undocumented step!
(gimp-drawable-update drawable startX startY lenghtX lengthY)
OR
Manually:
Hide and then unhide the layer by toggling its “eyeball” in the
Layers window. At this point the projection is updated to reflect that
the pixel at [1,1] has been painted black.
——–
“It is amazing what you can accomplish if you do
not care who gets the credit.” — Harry S. Truman