Skip to content

Commit

Permalink
Add alpha threshold for better cropping and outlining
Browse files Browse the repository at this point in the history
  • Loading branch information
DASPRiD committed Nov 15, 2015
1 parent b607fa6 commit 06079eb
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions telegram-sticker.py
Expand Up @@ -11,14 +11,17 @@
import math
from array import array

def python_telegram_sticker(timg, tdrawable):
def python_telegram_sticker(timg, tdrawable, alphaThreshold):
timg.undo_group_start()

# Merge all layers
pdb.gimp_image_merge_visible_layers(timg, 0)
imageLayer = timg.layers[0]

# Apple alpha threshhold
pdb.gimp_levels(imageLayer, 4, alphaThreshold, 255, 1, 0, 255);

# Crop and resize image
imageLayer = timg.layers[0]
pdb.plug_in_autocrop(timg, imageLayer)

newWidth, newHeight = resizeToTargetSize(timg)
Expand Down Expand Up @@ -176,10 +179,13 @@ def resizeToTargetSize(timg):
"Ben Scholzen 'DASPRiD'",
"Ben Scholzen 'DASPRiD'",
"2015",
"<Image>/Filters/Generic/Telegram Sticker",
"RGB*, GRAY*",
[],
"<Image>/Filters/Generic/Telegram Sticker...",
"RGB*",
[
(PF_SLIDER, "alphaThreshold", "_Alpha threshold", 30, (0, 255, 1)),
],
[],
python_telegram_sticker)

main()

0 comments on commit 06079eb

Please sign in to comment.