[Android Themes] Kdio:
Hey Mr.G

Sorry again but ... I can't contain myself ... :p

I thought with myself: "How cool would be an Batt animation like this?"

So ... included a toggle to you command to keep the original size while scaling.

Then I've concluded that the images are the same name and I would not able to use them for the animation ... so ...

You will see now the possibility of replacing the name of the result so, at end, you will only merge all the results!!! :D

New code:

import os
import time
import datetime
import shutil
from gimpfu import *

pdb = gimp.pdb

#################################################
# Routine that executes the transformations
#################################################
class DoTransform:
def __init__(self):
pass
def applyMod(self, image, new_width, new_height, keep_size, sharpeness, radius, amount, threshold):
layer = image.layers[0]
drawable = layer
is_indexed = pdb.gimp_drawable_is_indexed(drawable)
is_gray = pdb.gimp_drawable_is_gray(drawable)
is_rgb = pdb.gimp_drawable_is_rgb(drawable)

##################
# Convert RGB
##################
if is_rgb == False:
pdb.gimp_image_convert_rgb(image)
##################

##################
# Scale Layer
##################
if ((new_width > 0) and (new_height > 0)):
pdb.gimp_layer_scale(layer, new_width, new_height, True)
##################

##################
# Sharpen
##################
if (sharpeness > 0):
i = pdb.plug_in_sharpen(image, drawable, sharpeness)
##################

##################
# UnSharp Mask
##################
if (sharpeness == 0):
if ((radius > 0) or (amount > 0) or (threshold > 0)):
pdb.plug_in_unsharp_mask(image, drawable, radius, amount, threshold)
##################

##################
# Reinforce the Canvas Size
##################
if keep_size == True:
pdb.gimp_layer_resize_to_image_size(layer)
##################

################################################
# DO NOT EDIT BELOW THIS LINE
# Harmfull - Toxic - Radioactive
################################################
def create_tree(input_folder, output_folder):
for dirpath, dirnames, filenames in os.walk(input_folder):
os.mkdir(os.path.join(output_folder, dirpath[1+len(input_folder):]))
return

def resizeProcess(input_folder, output_folder, name_from, name_to, new_width, new_height, keep_size, sharpeness, radius, amount, threshold):

doTransform = DoTransform()

# Create the output folder structure
timestamp = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d_%H-%M-%S')
output_folder = os.path.join(output_folder , timestamp)
create_tree(input_folder, output_folder)

for root, dirs, files in os.walk(input_folder):
for f in files:
inputFile = os.path.join(root, f)
filename, ext = os.path.splitext(inputFile)
outputFile = inputFile.replace(input_folder, output_folder)

# Processes only images (PNG & JPG)
# Other filetypes are copied
if (ext != ".png"):
if (ext != ".jpg"):
shutil.copy(inputFile, outputFile)
continue

is_9 = (".9.png" in inputFile)

image = pdb.gimp_file_load(inputFile, inputFile)

doTransform.applyMod(image, new_width, new_height, keep_size, sharpeness, radius, amount, threshold)

if (name_from != ""):
outputFile = outputFile.replace(name_from, name_to)

pdb.gimp_file_save(image, image.layers[0], outputFile, outputFile)

double_check = False

register(
"Mr_Green_Resizer",
"Batch resizes images",
"Batch resizes images",
"Kdio",
"Kdio",
"2014",
"Mr Green Resizer...",
"",
[
(PF_DIRNAME, "input_folder", "_Input Folder", "c:/gimp/in"),
(PF_DIRNAME, "output_folder", "_Output Folder", "c:/gimp/out"),
(PF_STRING, "name_from", "Replace This", ""),
(PF_STRING, "name_to", "By This", ""),
(PF_INT, "new_width", "New Width", 0),
(PF_INT, "new_height", "New Height", 0),
(PF_BOOL, "keep_size", "Keep Source Size", 0),
(PF_SLIDER, "sharpeness", "Sharpeness", 0, (0, 99, 1)),
(PF_SLIDER, "radius", "Unsharp Radius", 0, (0, 500, 0.1)),
(PF_SLIDER, "amount", "Unsharp Amount", 0, (0, 10, 0.01)),
(PF_SLIDER, "threshold", "Unsharp Threshold", 0, (0, 255, 1)),
],
[],
resizeProcess,
menu="<Image>/Filters",
)

main()

[MENTION=5282154]pas2001[/MENTION] --> My friend, you are the Battery Master here ... does this accomplish something ?

Thank you.

.