I’m trying to code a Python Fu plugin for GIMP, but it doesn’t appear in my menus. Is there a mistake in my code ? How can I fix this ? Thank you a lot for reading me !
#!/usr/bin/env python
from gimpfu import *
import random as rd
def encode(image, drawable):
newDrawable = drawable
width = pdb.gimp_image_width(image)
height = pdb.gimp_image_height(image)
initialLayer = pdb.gimp_image_get_active_layer(image)
title1 = ""
title2 = ""
for k in range(10):
title1 += str(rd.randint(0,10))
title2 += str(rd.randint(0,10))
layer1 = pdb.gimp_layer_new(image, width, height, 0, "title1", 100, 0)
layer2 = pdb.gimp_layer_new(image, width, height, 0, "title2", 100, 0)
image.add_layer(layer1)
image.add_layer(layer2)
# Passe en revue l'intégralité des pixels
for x in range (width):
for y in range(height):
#Lecture
pdb.gimp_image_set_active_layer(image, initialLayer)
newDrawable = image.layers[2]
pixel = pdb.gimp_drawable_get_pixel(newDrawable, x, y)[1]
#Mélange aléatoire des valeurs RVB
newPixel1 = (rd.randint(0,pixel[0]+1), rd.randint(1,pixel[1]+1), rd.randint(2,pixel[2]+1))
newPixel2 = (pixel[0] - newPixel1[0], pixel[1]- newPixel1[1], pixel[2]- newPixel1[2])
#Écriture
pdb.gimp_image_set_active_layer(image, layer1)
newDrawable = image.layers[1]
pdb.gimp_drawable_set_pixel(newDrawable, x, y, 3, newPixel1)
pdb.gimp_drawable_update(newDrawable, 0, 0, width, height)
pdb.gimp_image_set_active_layer(image, layer2)
newDrawable = image.layers[0]
pdb.gimp_drawable_set_pixel(newDrawable, x, y, 3, newPixel2)
pdb.gimp_drawable_update(newDrawable, 0, 0, width, height)
register(
"python_fu_encode",
"Encodes an image into two ones.",
"Creates two layers. For each pixel, a random amount of intensity will be removed and added to one of the layers ; the other layer gets the rest.",
"Scapin", "Scapin", "2024",
"Encode",
"<Image>/Filters/Encode"
"RGB"
[
(PF_IMAGE, "image", "Takes current image", None),
(PF_DRAWABLE, "drawable", "Input layer", None)
],
[],
encode)
main()
I tried ;
-changing the plugin file pathes
-reinstalling/updating GIMP
-changing the structure of the register function
New contributor
Noah Bogue is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.