Last active
July 28, 2018 13:10
-
-
Save tuaplicacionpropia/646cbcfb38f57b4390b62716d7fe9e21 to your computer and use it in GitHub Desktop.
Gimp Frame Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import random | |
from gimpfu import * | |
import sys | |
import locale | |
from PIL import Image | |
from PIL.ExifTags import TAGS | |
from datetime import datetime | |
def get_exif(fn): | |
ret = {} | |
i = Image.open(fn) | |
info = i._getexif() | |
for tag, value in info.items(): | |
decoded = TAGS.get(tag, tag) | |
ret[decoded] = value | |
return ret | |
#'DateTime': u'2017:12:21 10:52:44' | |
def get_fecha (fn): | |
result = None | |
data = get_exif(fn) | |
keys = ['DateTimeOriginal', 'DateTime'] | |
for key in keys: | |
if key in data: | |
dateTxt = data[key] | |
datetime_object = datetime.strptime(dateTxt, '%Y:%m:%d %H:%M:%S') | |
locale.setlocale(locale.LC_ALL, 'es_ES.UTF-8') | |
result = datetime_object.strftime("%A %-d de %B de %Y %H:%M:%S") | |
break | |
return result | |
def frame1(image, drawable): | |
options = ['a', 'b', 'c'] | |
option = random.choice(options) | |
frameUrl = '/media/jmramoss/ALMACEN/video_12_primaria/frames/touse/rectangle_13x10' + option + '.png' | |
newLayer = pdb.gimp_file_load_layer(image, frameUrl) | |
frame = pdb.gimp_file_load(frameUrl, frameUrl) | |
# activeLayer = pdb.gimp_image_get_active_layer(frame) | |
# newLayer = pdb.gimp_layer_copy(activeLayer, 100) | |
pdb.gimp_image_insert_layer(image, newLayer, None, -1) | |
pdb.gimp_image_resize(image, frame.width, frame.height, 0, 0) | |
pdb.gimp_image_set_active_layer(image, image.layers[0]) | |
fecha = get_fecha(image.filename) | |
if fecha is not None: | |
text_layer = pdb.gimp_text_fontname(image, newLayer, 45, 767, fecha, 5, True, 18, PIXELS, 'Sans') | |
pass | |
register( | |
"python-fu-frame1", | |
"Make Frame1", | |
"Make Frame1", | |
"Jesus Maria Ramos Saky", | |
"Jesus Maria Ramos Saky", | |
"2018", | |
"Make Frame1", | |
"RGB*, GRAY*", | |
[ | |
(PF_IMAGE, "image", "Input image", None), | |
(PF_DRAWABLE, "drawable", "Input drawable", None) | |
# (PF_BOOL, "copy", "Make a JPEG copy", TRUE), | |
# , | |
# (PF_SLIDER, "whirl", "Whirl angle", 90, (-360, 360, 1)), | |
# (PF_FLOAT, "pinch", "Pinch amount", 0), | |
# (PF_FLOAT, "radius", "radius", 1) | |
], | |
[], | |
frame1, menu="<Image>/Filters/Enhance") | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment