Reputation: 3555
I am trying to merge multiple PNG images into a single PDF file. I can do that with this command:
convert output/*.png all_plots.pdf
However, I also want to reduce the size or quality (ultimately to reduce the output file size) of the input PNG files before they get added to the PDF. I tried this command:
convert output/*.png -quality 0 all_plots.pdf
And also this
convert -quality 0 output/*.png all_plots.pdf
But it does not seem to be doing anything. How are you supposed to set the arguments so that the adjustments are applied to all input PNG files found by globbing?
For reference, there is documentation here and here and a similar question here, but I was not able to find an answer for this among them.
Upvotes: 1
Views: 348
Reputation: 207465
It might help if you showed the sizes and types of input files you have, as this technique may not be applicable to all image types... but one way would be to reduce the number of colours in your files.
So, let's take this as a starting image:
convert -size 600x400 xc:gray +noise random p1.png
And copy that to make p2.png
and p3.png
, then combine them into a 3-page PDF:
convert p[123].png result.pdf
and check the size:
-rw-r--r-- 1 mark staff 2214667 16 Nov 10:11 result.pdf
Now, we load the input pages and reduce their colours to, say 128:
convert p[123].png -colors 128 result.pdf
and check the size:
-rw-r--r-- 1 mark staff 674921 16 Nov 10:12 result.pdf
That's better, 670kB instead of 2.2MB.
Upvotes: 1