x11-desktop / scripts /gimp_example.py
3v324v23's picture
Refactor agent to use Computer interface and add deployment script
4408617
#!/usr/bin/env python
from gimpfu import *
def create_image(width, height, text):
# Create a new image
img = pdb.gimp_image_new(width, height, RGB)
# Create a new layer
layer = pdb.gimp_layer_new(img, width, height, RGB_IMAGE, "Background", 100, NORMAL_MODE)
pdb.gimp_image_insert_layer(img, layer, None, 0)
# Fill with white
pdb.gimp_context_set_foreground((255, 255, 255))
pdb.gimp_drawable_fill(layer, FOREGROUND_FILL)
# Add text
pdb.gimp_context_set_foreground((0, 0, 0))
text_layer = pdb.gimp_text_fontname(img, None, 10, 10, text, 0, True, 24, PIXELS, "Sans")
# Display the image
display = pdb.gimp_display_new(img)
register(
"python_fu_create_image",
"Create a new image with text",
"Creates a new image with the specified dimensions and text",
"AI Agent",
"AI Agent",
"2024",
"<Toolbox>/Xtns/Languages/Python-Fu/Test/_Create Image...",
"",
[
(PF_INT, "width", "Width", 1920),
(PF_INT, "height", "Height", 1080),
(PF_STRING, "text", "Text", "Hello from AI Agent!"),
],
[],
create_image)
main()