Bug#1009257: Option to convert white to transparency
Regarding the following, written by "Jeff" on 2022-04-12 at 09:42 Uhr +: If you look at the post-processing tab of the scan window, you should be able to invoke any of the user-defined tools as part of your workflow. I saw that, and then promptly forgot about it when I found out it actually doesn't post-process the PDF file, which was what I wanted at the time. But yeah, using `mogrify -transparent white %i` as part of the post-processing pipeline works. For completeness, here is how to chuck a watermark onto the PDF generated with transparent background: ``` convert -size 4330x -density 300x300 -background transparent -gravity center -fill grey label:"This is a long text" -trim -rotate -54 +repage -resize $((2480*.8))x$((3508*.8)) -extent 2480x3508 /tmp/watermark.png convert /tmp/watermark.png /tmp/watermark.pdf pdftk from-gscan2pdf.pdf background /tmp/watermark.pdf output /tmp/target.pdf ``` I am still trying to combine the first two commands into one, see [here](https://github.com/ImageMagick/ImageMagick/discussions/5039) for the discussion. -- .''`. martin f. krafft @martinkrafft : :' : proud Debian developer `. `'` http://people.debian.org/~madduck `- Debian - when you have better things to do than fixing systems "you know you're a hopeless geek when you misspell 'date' as 'data'" -- branden robinson digital_signature_gpg.asc Description: Digital GPG signature (see http://martin-krafft.net/gpg/sig-policy/999bbcc4/current)
Bug#1009257: Option to convert white to transparency
On 11/04/2022 15:35, martin f krafft wrote: Then I think a better UI/UX for user-defined tools, and possibly the ability to invoke any subset of them automatically during the scan would do just fine. I'm sure the UI/UX could be improved. I'd love to hear any suggestions. If you look at the post-processing tab of the scan window, you should be able to invoke any of the user-defined tools as part of your workflow. Also, have a look at how Geeqie does user-defined actions, using |.desktop| entries. Not the nicest, but it's a standard, and means it can easily be brought into the menus. Having units like |.desktop| files also means we could start a |contrib| collection for gscan2pdf, rather than providing them all off the shelf for everyone. I'd not seen Geeqie before. Thanks for the heads-up. OpenPGP_signature Description: OpenPGP digital signature
Bug#1009257: Option to convert white to transparency
Regarding the following, written by "Jeff" on 2022-04-11 at 06:05 Uhr +: The user-defined tools operate on the source images, not the resulting PDF. I think you might be mixing them up with the post-save hook, which does operate on the PDF. Oh yes, then I was indeed confused. Then I think a better UI/UX for user-defined tools, and possibly the ability to invoke any subset of them automatically during the scan would do just fine. Also, have a look at how Geeqie does user-defined actions, using `.desktop` entries. Not the nicest, but it's a standard, and means it can easily be brought into the menus. Having units like `.desktop` files also means we could start a `contrib` collection for gscan2pdf, rather than providing them all off the shelf for everyone. Best, -- .''`. martin f. krafft @martinkrafft : :' : proud Debian developer `. `'` http://people.debian.org/~madduck `- Debian - when you have better things to do than fixing systems "i wish i hadn't slept all day, it's really lowered my productivity" -- robert mcqueen digital_signature_gpg.asc Description: Digital GPG signature (see http://martin-krafft.net/gpg/sig-policy/999bbcc4/current)
Bug#1009257: Option to convert white to transparency
On 10/04/2022 20:36, martin f krafft wrote: Regarding the following, written by "Jeff" on 2022-04-10 at 12:52 Uhr +: Can't this be achieved with a user defined tool? Sure thing, for instance: |convert -size 2480x3508 -depth 300x300 -transparent white in.pdf out.pdf | I see four problems with this though: 1. This operation would be a lot faster on the PNM files, rather than first writing the PDF, and then basically accessing the PDF bitmaps page-wise for this operation; The user-defined tools operate on the source images, not the resulting PDF. I think you might be mixing them up with the post-save hook, which does operate on the PDF. 3. A user-defined tool does not have access to the resolution to be used, unlike gscan2pdf. I can calculate the dimensions, but only if I have the resolution; The user-defined tools currently offer 3 variables, %i for input filename, %o for output filename, and %r for resolution. I understand your point, but the argument can be made about all of the post-processing tools built-in, and the question becomes which one of those are so commonly used that they should be built-in. I never use unsharp mask, negation, brigthness/contrast, or even OCR, but they are built-in. Absolutely. I was not suggesting it shouldn't be added, only provide a workaround until I found time to do so. OpenPGP_signature Description: OpenPGP digital signature
Bug#1009257: Option to convert white to transparency
Regarding the following, written by "Jeff" on 2022-04-10 at 12:52 Uhr +: Can't this be achieved with a user defined tool? Sure thing, for instance: ``` convert -size 2480x3508 -depth 300x300 -transparent white in.pdf out.pdf ``` I see four problems with this though: 1. This operation would be a lot faster on the PNM files, rather than first writing the PDF, and then basically accessing the PDF bitmaps page-wise for this operation; 2. The ImageMagick conversion really messes with the PDF file in ways I haven't figure out yet. If I apply it to the PNM files, there is no quality loss; 3. A user-defined tool does not have access to the resolution to be used, unlike gscan2pdf. I can calculate the dimensions, but only if I have the resolution; 4. Invoking user-defined tools is cumbersome, especially if you want to do so multiple times (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1007197) I understand your point, but the argument can be made about all of the post-processing tools built-in, and the question becomes which one of those are so commonly used that they should be built-in. I never use unsharp mask, negation, brigthness/contrast, or even OCR, but they are built-in. -- .''`. martin f. krafft @martinkrafft : :' : proud Debian developer `. `'` http://people.debian.org/~madduck `- Debian - when you have better things to do than fixing systems "the difference between genius and stupidity is that genius has it's limits." -- albert einstein digital_signature_gpg.asc Description: Digital GPG signature (see http://martin-krafft.net/gpg/sig-policy/999bbcc4/current)
Bug#1009257: Option to convert white to transparency
Can't this be achieved with a user defined tool? OpenPGP_signature Description: OpenPGP digital signature
Bug#1009257: Option to convert white to transparency
Package: gscan2pdf Version: 2.12.6-1 Severity: wishlist When scanning documents, I basically end up with black-white images, either because the scanner already provides line-drawing input, or because of the threshold filter. In this case, it would be fantastic if the white background could be replaced with transparency. It renders the same as PDF, but the benefit is that it's easy to later add a watermark to the PDF, which is not possible if the background is non-transparent. Or well, then you just can't see the watermark. Thanks, martin -- System Information: Debian Release: bookworm/sid APT prefers unstable APT policy: (500, 'unstable'), (1, 'experimental') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 5.16.0-5-amd64 (SMP w/8 CPU threads; PREEMPT) Kernel taint flags: TAINT_WARN, TAINT_FIRMWARE_WORKAROUND Locale: LANG=en_NZ, LC_CTYPE=en_NZ.UTF-8 (charmap=UTF-8), LANGUAGE=en_NZ:en Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages gscan2pdf depends on: ii imagemagick8:6.9.11.60+dfsg-1.3+b2 ii imagemagick-6.q16 [imagemagick]8:6.9.11.60+dfsg-1.3+b2 ii libconfig-general-perl 2.63-1 ii libdate-calc-perl 6.4-1.1 ii libfilesys-df-perl 0.92-6+b7 ii libgoocanvas2-perl 0.06-2 ii libgtk3-imageview-perl 10-1 ii libgtk3-perl 0.038-1 ii libgtk3-simplelist-perl0.21-1 ii libhtml-parser-perl3.78-1 ii libimage-magick-perl 8:6.9.11.60+dfsg-1.3 ii libimage-sane-perl 5-1+b2 ii liblist-moreutils-perl 0.430-2 ii liblocale-codes-perl 3.70-1 ii liblocale-gettext-perl 1.07-4+b2 ii liblog-log4perl-perl 1.54-1 ii libossp-uuid-perl [libdata-uuid-perl] 1.6.2-1.5+b10 ii libpdf-builder-perl3.023-1 ii libproc-processtable-perl 0.634-1+b1 ii libreadonly-perl 2.050-3 ii librsvg2-common2.52.5+dfsg-3+b1 ii libset-intspan-perl1.19-2 ii libtiff-tools 4.3.0-6 ii libtry-tiny-perl 0.31-1 ii sane-utils 1.1.1-5 Versions of packages gscan2pdf recommends: ii djvulibre-bin 3.5.28-2 ii pdftk 2.02-5+b1 ii pdftk-java [pdftk] 3.2.2-1 ii tesseract-ocr 4.1.1-2.1 ii unpaper 6.1-2+b2 ii xdg-utils 1.1.3-4.1 gscan2pdf suggests no packages. -- no debconf information -- .''`. martin f. krafft @martinkrafft : :' : proud Debian developer `. `'` http://people.debian.org/~madduck `- Debian - when you have better things to do than fixing systems