[Android Themes] Kdio:
Hi xxmrgreenxx

From the help of Gimp, about the "Sharpen" tool --> "Make image sharper (

less powerful than Unsharp Mask

)"

So, I've produced both for you to test more confortably ;)

If "Sharpness" > 0 then it will be used, otherwise it will use "Unsharp Mask". If only New width and height are used it will only resize.

And made the following experiment:

With these View attachment Stock.Batts.zip (48x54) in the Input Folder.

1st Round

(only scaling)

New Width: 32

New Height: 36

Sharpness: 0

Radius: 0

Amount: 0

Threshold: 0

2sd Round

(scaling + sharpen)

New Width: 32

New Height: 36

Sharpness: 30

Radius: 0

Amount: 0

Threshold: 0

3rd Round

(scaling + Unsharp Mask)

New Width: 32

New Height: 36

Sharpness: 0

Radius: 5.0

Amount: 0.20

Threshold: 0

Zooming in the result images I've felt a better result using the Unsharp Mask. Try it with different values too.

As further information:

Using Unsharp Mask on resized images

Please, sweat the small stuff

The new code is:

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, 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)
##################

################################################
# 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, new_width, new_height, sharpeness, radius, amount, threshold):
if ((new_width == 0) or (new_height == 0)):
pdb.gimp_message("Width/Height invalid value(s). Please verify.")
return

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, sharpeness, radius, amount, threshold)

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_INT, "new_width", "New Width", 0),
(PF_INT, "new_height", "New Height", 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()

Nice regards.

.