from gimpfu import *
# 1012982852
def antiquify(image, rndm_pct, rndm_rcount, randomize, seed, horizontal, vertical, low_threshold, high_threshold, spread_amount_x, spread_amount_y, filename):
pdb.gimp_undo_push_group_start(image)
for subimage in gimp.image_list():
opacity = 80.0
pdb.gimp_context_set_opacity(opacity)
drawable=subimage.active_layer
pdb.plug_in_randomize_pick(image,drawable,rndm_pct, rndm_rcount, randomize, seed)
# pdb.plug_in_spread(subimage,drawable,spread_amount_x, spread_amount_y)
# pdb.plug_in_spread(subimage,drawable,spread_amount_x, spread_amount_y)
# pdb.plug_in_gauss_rle2(subimage,drawable,horizontal, vertical)
opacity = 100.0
pdb.gimp_context_set_opacity(opacity)
pdb.gimp_threshold(drawable, low_threshold, high_threshold)
images = gimp.image_list()
# num_images, image_ids = pdb.gimp_image_list()
pdb.file_pdf_save_multi(len(images), images, False, False, False, filename, filename)
pdb.gimp_undo_push_group_end(image)
register(
"python-fu-antiquify",
"Make a LaTeX document antique",
"",
"Masum Billal",
"Masum Billal",
"2022",
"Antiquify",
"",
[
# basic parameters are: (UI_ELEMENT, "variable", "label", Default)
(PF_IMAGE, "image", "takes current image", None),
(PF_SLIDER, "rndm_pct", "Random Percent for Pick", 10, (0, 100, .5)),
(PF_SLIDER, "rndm_rcount", "Number of Iteration for Pick", 1, (0, 10, 1)),
(PF_BOOL, "randomize", "Randomize or not for Pick", True),
(PF_INT, "seed", "Seed of randomization for Pick", 1),
(PF_SLIDER, "horizontal", "Horizontal for Gaussian blur", .5, (0, 10, .5)),
(PF_SLIDER, "vertical", "Vertical for Gaussian blur", .5, (0, 10, .5)),
(PF_SLIDER, "low_threshold", "Threshold low", 200, (0, 255, 1)),
(PF_SLIDER, "high_threshold", "Threshold high", 255, (0, 255, 1)),
(PF_SLIDER, "spread_amount_x", "Horizontal spread", 2, (0, 20, 1)),
(PF_SLIDER, "spread_amount_y", "Vertical spread", 2, (0, 20, 1)),
(PF_STRING, "filename", "PDF Filename", None),
],
[],
antiquify,
menu="<Image>/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