I'm puzzled how one should be able to that. I've tried many ways and always there is something weird.
Let's start with the obvious:
https://imagemagick.org/script/command- ... essing.php
When needed, explicit image formats can be given as mentioned earlier, as in the following.
magick gif:fd:3 jpg:fd:4 -append tif:fd:5
Code: Select all
$ convert --version
Version: ImageMagick 6.8.9-9 Q16 x86_64 2018-09-28 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC Modules OpenMP
Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib
$ cat test.pdf | convert -quiet pdf:-[0] -thumbnail "100x>" png:fd:42 42>thumb.png
$ ls -la thumb.png fd\:42
-rw------- 1 jmto jmto 24372 Dec 12 14:13 fd:42
-rw-rw-r-- 1 jmto jmto 0 Dec 12 14:13 thumb.png
This would work if it would do as the documentation says.
Well, what's the default output then? It's that ok.
Code: Select all
$ cat Jukola.pdf | convert -quiet pdf:-[0] -thumbnail "100x>" fd:42 42>thumb.png; ls -la fd:42 thumb.png ; file thumb.png
ls: cannot access 'fd:42': No such file or directory
-rw-rw-r-- 1 jmto jmto 20145 Dec 12 14:17 thumb.png
thumb.png: PNG image data, 100 x 147, 8-bit/color RGBA, non-interlaced
$ cat test.pdf | convert -quiet pdf:-[0] -thumbnail "100x>" fd:42 42>thumb.png; ls -la fd:42 thumb.png ; file thumb.png
ls: cannot access 'fd:42': No such file or directory
-rw-rw-r-- 1 jmto jmto 41715 Dec 12 14:17 thumb.png
thumb.png: Netpbm image data, size = 100 x 139, rawbits, pixmap
This would work if there would be default output format, like PNG.
At this point you might think fd:42 what's wrong with just using stdout? Let's try that then.
Code: Select all
$ cat Jukola.pdf | convert -quiet pdf:-[0] -thumbnail "100x>" png:- 1>thumb.png; ls -la thumb.png ; file thumb.png
-rw-rw-r-- 1 jmto jmto 20145 Dec 12 14:19 thumb.png
thumb.png: PNG image data, 100 x 147, 8-bit/color RGBA, non-interlaced
$ cat test.pdf | convert -quiet pdf:-[0] -thumbnail "100x>" png:- 1>thumb.png; ls -la thumb.png ; file thumb.png
-rw-rw-r-- 1 jmto jmto 24372 Dec 12 14:19 thumb.png
thumb.png: PNG image data, 100 x 139, 8-bit/color RGBA, non-interlaced
$ cat Keskuspuisto18.pdf | convert -quiet pdf:-[0] -thumbnail "100x>" png:- 1>thumb.png; ls -la thumb.png ; file thumb.png
-rw-rw-r-- 1 jmto jmto 27024 Dec 12 14:20 thumb.png
thumb.png: data
$ head -5 thumb.png
**** Error: Ignoring changes to the graphic state after operator 'W'.
Output may be incorrect.
**** Error reading a content stream. The page may be incomplete.
Output may be incorrect.
**** Error: Form stream has unbalanced q/Q operators (too many q's)
This would work if I would suppress the errors, or the errors would be written to STDERR.
So how to do this so that it works? There are multiple ways, but they all have problems. One how should solve this simple problem?
Task is: I want to generate thumbnails of PDF documents by writing the PDF to convert with pipe, and by reading the thumbnail with some file description (42 or stdout). How to do this?