Script-Fu levels Newbie Gimp 2.10 Linux MX - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: Script-Fu levels Newbie Gimp 2.10 Linux MX (/Thread-Script-Fu-levels-Newbie-Gimp-2-10-Linux-MX) |
Script-Fu levels Newbie Gimp 2.10 Linux MX - Anthony Buff - 11-27-2022 Hey there! Newbie here trying to tackle a task above my scope of knowledge. I am trying to change the intensity of the low output levels in a batch of pdf files that are one page each. All I'm trying to do is reduce the amount of black ink used for printing as my printer doesn't have an economy mode. I created a script in bash that splits the PDFs into separate pages for easy "layer free"/"single layer" editing and have been using bimp successfully but it'll be just great if I could accomplish this with script-fu as it would save me a ton of time. The attached pic shows the levels setting I'd like to achieve: I reviewed the script-fu documentation, googled for hours, watched a tutorial video, used the console and the procedure browser rendered this: Code: (gimp-drawable-levels drawable channel low-input high-input clamp-input gamma low-output high-output clamp-output). Yet I was unable to find working examples online and couldn't replace the variables with their expected values. Since the files have only one layer, Could "Drawable" be "TheCurrentLoadedImage"? (whatever the correct syntax should be to refer to it). I'd be truly grateful just to see a working example that could run in the console or even better in a bash script that could accomplish such simple task. Thanks in advance!!! RE: Script-Fu levels Newbie Gimp 2.10 Linux MX - Ofnuts - 11-27-2022 (11-27-2022, 08:31 AM)Anthony Buff Wrote: Hey there! A "drawable" is something you can draw onto; layer, but also channel or layer mask. In your case, it is typically obtained with (gimp-image-get-active-layer image). But seriously, it is so much easier with ImageMagick (in your repo): Basic code: Code: convert Source.png +level 14% Target.png On recent versions use magick convert instead of just (convert). You can of course put that in a loop in bash. This is 14% because 35 / 255 = 0.1372. If you want to replace the image with the modified version: Code: mogrify +level 14% Target.png So if you want to process a whole directory: Code: mogrify +level 14% *.png With a bit more contrived parameters you can also use convert with wildcards: Code: convert *.png -set filename:base "%[basename]" "converted/%[filename:base].png" If you use IM with PDF files, you may have to edit /etc/ImageMagick-6/policy.xml to enable PDF processing, because it is sometimes disabled by default. Also remember that this converts your PDF (vector graphics mostly) to bitmap. If you want to change mostly the text color, using a PDF utility to change the text color directly in the PDF could be a much better solution. RE: Script-Fu levels Newbie Gimp 2.10 Linux MX - rich2005 - 11-27-2022 Sorry I can't do script-fu For linux users ImageMagick (IM), because of backward compatibility issues, most linux is still IM6 The IM developers have a very good single file static IM7 'magick' for Linux If you have permission issues check with IM identify -list policy you can make a ~/.config/ImageMagick/policy.xml (saves delving into root) Code: <policymap> ------------ However a non-IM non-Gimp proposition. pdftoppm part of poppler-utils package will extract the pages @ 300 ppi Code: pdftoppm -jpeg -r 300 manual.pdf output Gimp has to come into it somewhere Using Filters -> Generic -> GEGL graph you can find a good value for the Colors -> Exposure filter (or you can just use the filter as long as you understand the syntax) [attachment=9095] You do need the GEGL package, it might not be installed. Gimp will install libgegl but not necessarily the stand-alone GEGL For a single image Code: gegl in.jpg -o out.jpg -- exposure exposure=3.2 Putting those together in a bash script with img2pdf to combine the result. Code: #!/bin/bash Please excuse the 'hard encoded' names and paths, it is just a quick test. I am sure you will fix that. Rendered a 130 page PDF to a rather large new (all graphic) PDF in 1 min 30 seconds. Edit: I was assuming that speed is a factor. Just got round to trying BIMP on the same 130 images, using the color curve correction, and that is only 2 mins and a couple of seconds. RE: Script-Fu levels Newbie Gimp 2.10 Linux MX - Anthony Buff - 11-28-2022 The easier the better. I'll try your suggestions and will report back. Thank you, thank you , thank you !!! ...and how quick it was too! Incidentally, I will be coming back for more on my scripting efforts. Boy, I'm happy there are alternatives for what I need to do with this!!! Best regards!!! P.S. The pic... lol It was worth the time putting that together considering the amount of hours I've been banging my head with this. |