[Python] Why is my Python script not recognized by GIMP?

Discussão em 'Python' iniciado por Stack, Fevereiro 17, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to write a GIMP script to take information from a csv, place it onto a template image, save the file, and do so for every row of the csv.

    The csv is:

    location,name,address1,address2,phone


    Here is the script:

    import csv
    from gimpfu import *

    def create_image_from_csv(csv_file, template_file):
    with open(csv_file, 'r') as f:
    reader = csv.DictReader(f)
    for row in reader:
    location = row['location']
    name = row['name']
    address1 = row['address1']
    address2 = row['address2']
    phone = row['phone']

    template = pdb.gimp_file_load(template_file, template_file)

    image_width = template.width
    image_height = template.height

    text_layer = pdb.gimp_text_fontname(template, None, 10, 10, name, -1, True, 20, PIXELS, "Sans")
    pdb.gimp_item_set_name(text_layer, "Name Layer")

    pdb.gimp_text_fontname(template, None, 10, 40, address1, -1, True, 20, PIXELS, "Sans")
    pdb.gimp_text_fontname(template, None, 10, 70, address2, -1, True, 20, PIXELS, "Sans")
    pdb.gimp_text_fontname(template, None, 10, 100, phone, -1, True, 20, PIXELS, "Sans")

    output_file = location + '-header.png'
    pdb.gimp_file_save(template, template.active_layer, output_file, output_file)

    pdb.gimp_image_delete(template)

    create_image_from_csv('C:\Users\env25\Downloads\Gimpautotest\store_list.csv', 'C:\Users\env25\Downloads\Gimpautotest\testtemp.png')


    I've tried adding

    #!/usr/bin/python


    at the top but no luck.

    I did confirm scripts can be recognized by creating a super simple HelloWorld.py style script and GIMP did pick it up.

    I am on Windows 11, using GIMP 2.10.38 and Python 2.7.18.

    I have seen ImageMagick suggested, but I am in a sort of locked down space software-wise, so I'm hoping to make GIMP work.

    Continue reading...

Compartilhe esta Página