Sat Jul 18, 2020 9:41 am
from gimpfu import *
#debug:
#"c:\program files\gimp 2\bin\gimp-2.10" --verbose --console-messages
import math
import csv
from gimpfu import *
def dataModeling(pos):
data_x=[]
data_y=[]
for i,row_i in enumerate(pos):
data_x.append(row_i[1])
data_y.append(row_i[2])
return data_x, data_y
def openLogo(path_logo):
image_logo = pdb.file_png_load(path_logo, path_logo)
display = pdb.gimp_display_new(image_logo)
pdb.gimp_edit_copy(image_logo)
return
def layerCreation(data_x, data_y):
for i, x_el in enumerate(data_x):
y_el=data_y[i]
layer = pdb.gimp_layer_new(image, width_logo, height_logo, RGB_IMAGE, "Logo", 100, OVERLAY_MODE)
layer_position = i
x_pos=int(float(x_el))-width_logo/2
y_pos=int(float(y_el))-height_logo/2
pdb.gimp_image_insert_layer(image, layer, None, layer_position)
pdb.gimp_layer_translate(layer, x_pos, y_pos)
floating_sel = pdb.gimp_edit_paste(layer, TRUE)
pdb.gimp_floating_sel_anchor(floating_sel)
return
def LogoPos():
path_pos = "PATH TO CSV"
path_img = "PATH TO BACKGROUNDIMG"
path_logo = "PATH TO LOGO"
width_logo = 213
file = open(path_pos)
pos = csv.reader(file, delimiter=",")
data_x, data_y = dataModeling(pos)
del data_x[0]
del data_y[0]
openLogo(path_logo)
image = pdb.file_jpeg_load(path_img, path_img)
display = pdb.gimp_display_new(image)
layerCreation(data_x, data_y)
print("Done.")
return
register(
"python-fu-logo-pos",
"Logo positioning",
"Position of Logos on predefined coordinates",
"Alexander Böttjer", "Alexander Böttjer", "2020",
"add logos",
"*", # type of image it works on (*, RGB, RGB*, RGBA, GRAY etc...)
[],[],
LogoPos, menu="<Image>/File") # second item is menu location
main()
Sat Jul 18, 2020 10:56 am