Created
February 7, 2017 07:47
-
-
Save josuigoa/188af325580f2f0fd7bd97980bf1124c to your computer and use it in GitHub Desktop.
Gimp plugin to export the layers to JPG images
This file contains hidden or 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 | |
from gimpfu import * | |
import glob | |
from os import listdir | |
import os | |
import time | |
import datetime | |
def run(timg, tdrawable): | |
ts = time.time() | |
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S') # 2012-12-15 01:21:05 | |
print "*** BEGIN *** layers_to_jpg" | |
print 'timg.filename:', timg.filename | |
print 'date:', st | |
ind = 0 | |
dir_name = os.path.dirname(timg.filename) | |
if not os.path.exists(dir_name + "\\jpg"): | |
os.mkdir(dir_name + "\\jpg") | |
# Loop over all the layers | |
for layer in timg.layers: | |
if ind < 10: | |
new_filename = dir_name + "\\jpg\\0" + str(ind) + ".jpg" | |
else: | |
new_filename = dir_name + "\\jpg\\" + str(ind) + ".jpg" | |
pdb.file_jpeg_save(timg, layer, new_filename, "raw_filename", 0.8, 0.5, 0, 0, timg.filename + " jpg", 0, 0, 0, 0) | |
print str(ind) + " --------------" | |
ind = ind+1 | |
print "*** END ***" | |
register( | |
"layers_to_jpg", | |
"Export the layers to JPG images", | |
"Export the layers to JPG images", | |
"Josu Igoa", | |
"Josu Igoa", | |
"2016", | |
"<Image>/Pluginak/Layers to JPG", "", | |
[], | |
[], | |
run | |
) | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment