(11-27-2022, 08:31 AM)Anthony Buff Wrote: 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!!!
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.