Fix script to make it runnable
This commit is contained in:
parent
7213ec13d4
commit
65df52ba90
@ -17,6 +17,7 @@
|
||||
# To view a copy of the GNU General Public License
|
||||
# visit: http://www.gnu.org/licenses/gpl.html
|
||||
#
|
||||
#
|
||||
# ------------
|
||||
#| Change Log |
|
||||
# ------------
|
||||
@ -26,6 +27,9 @@ from gimpfu import *
|
||||
|
||||
def python_fu_make_wallpaper(resX, resY, sourceFile, targetFile) :
|
||||
# create new image in resolution size
|
||||
resX = int(resX)
|
||||
resY = int(resY)
|
||||
|
||||
img = gimp.Image(resX, resY)
|
||||
|
||||
bg = img.new_layer("bg", resX, resY)
|
||||
@ -37,8 +41,8 @@ def python_fu_make_wallpaper(resX, resY, sourceFile, targetFile) :
|
||||
scaleX = (resX - 50.0) / pic.width
|
||||
scaleY = (resY - 50.0) / pic.height
|
||||
scale = min(scaleX, scaleY)
|
||||
x0 = int((resX - picX * scale) // 2)
|
||||
y0 = int((resY - picY * scale) // 2)
|
||||
x0 = int((resX - pic.width * scale) // 2)
|
||||
y0 = int((resY - pic.height * scale) // 2)
|
||||
x1 = resX - x0
|
||||
y1 = resY - y0
|
||||
pic.scale(x0, y0, x1, y1)
|
||||
@ -56,7 +60,7 @@ def python_fu_make_wallpaper(resX, resY, sourceFile, targetFile) :
|
||||
# desature for certain bgcolors
|
||||
colorHSV = color.to_hsv()
|
||||
if colorHSV[1] > 50 and colorHSV[2] > 50:
|
||||
img.merge_visible_layers(FALSE)
|
||||
merged = img.merge_visible_layers(FALSE)
|
||||
|
||||
img.add_layer(pdb.gimp_layer_copy(merged, FALSE))
|
||||
multi = img.layers[0]
|
||||
@ -70,8 +74,10 @@ def python_fu_make_wallpaper(resX, resY, sourceFile, targetFile) :
|
||||
sat.name = "sat"
|
||||
sat.mode = SATURATION_MODE
|
||||
|
||||
final = img.merge_visible_layers(FALSE)
|
||||
|
||||
# save
|
||||
pdb.gimp_file_save(GIMP_RUN_NONINTERACTIVE, img, img, targetFile, targetFile)
|
||||
pdb.gimp_file_save(img, final, targetFile, targetFile)
|
||||
|
||||
register(
|
||||
"python_fu_make_wallpaper",
|
||||
@ -80,13 +86,13 @@ register(
|
||||
"Sarah Ziesel",
|
||||
"Sarah Ziesel",
|
||||
"April 2020",
|
||||
"<Toolbox>/File/Create/Wallpaper"
|
||||
"RGB*",
|
||||
"<Toolbox>/Python-Fu/Make Wallpaper...",
|
||||
"",
|
||||
[
|
||||
(PF_SPINNER, "resX", _("Screen width"), 2560),
|
||||
(PF_SPINNER, "resY", _("Screen height"), 1440),
|
||||
(PF_FILE, "sourceFile", _("Source file"), None),
|
||||
(PF_STRING, "targetFile", _("Desired target path"), "/home/sarah/sync/private/pictures_converted/bandori_0001.jpg")
|
||||
(PF_SPINNER, "resX", "Screen width", 2560, (1, 9999, 1)),
|
||||
(PF_SPINNER, "resY", "Screen height", 1440, (1, 9999, 1)),
|
||||
(PF_FILE, "sourceFile", "Source file", "/home/sarah/sync/private/pictures/bandori/toxxtu77dsm41.jpg"),
|
||||
(PF_STRING, "targetFileName", "Desired target path", "/home/sarah/sync/private/pictures_converted")
|
||||
],
|
||||
[],
|
||||
python_fu_make_wallpaper)
|
||||
|
Loading…
Reference in New Issue
Block a user