0

I can get the current images open using gimp.image_list() but how can I export them to a single pdf? The function pdb.file_pdf_multi_save() does not work. I do not intend to use ImageMagick, not sure if it still works either.

This is not properly answered in this question: Export multi page pdf with gimp

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>/Filters/Noise",
)

main()
5
  • 2
    Better asked on StackExchange, since this is a programming matter. And when you do so, remember that "doesn't work" is not helpful: show what you have coded so far, and the results (or error messages).
    – xenoid
    Commented Mar 27, 2022 at 8:13
  • 1
    @xenoid - StackOverflow for code questions. They'll need to see some code though.
    – Billy Kerr
    Commented Mar 27, 2022 at 12:50
  • @BillyKerr hence the "show what you have coded so far" in my comment :) And who answers questions tagged gimp and python over there is anybody's guess :)
    – xenoid
    Commented Mar 27, 2022 at 12:56
  • @xenoid Maybe even the gimp-forum - for questions about scripting and plugins for gimp. It seems to be fairly active.
    – Billy Kerr
    Commented Mar 27, 2022 at 13:42
  • I intentionally left out the code because mine does more than just export to pdf and I wanted to see another approach.
    – Masum
    Commented Mar 27, 2022 at 20:45

1 Answer 1

-1

I was able to find an answer for this here.

https://www.gimp-forum.net/Thread-GIMP-Python-Fu-Export-all-open-images-to-pdf

2
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Apr 5, 2022 at 21:36
  • @Community people can go to the link and check the answer for themselves. And there were back to back discussions which I cannot put here all at the same thread.
    – Masum
    Commented Apr 7, 2022 at 3:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.