How can I use both ls and convert to transform all images files in a directory to a pdf ? Also I need to put the files in a certain order for example files like AA1.png,AA11.png need to respect this logical order.
Update (ls) and (convert) are available , but how can I used them together ?
To convert to a single PDF can be done in a single command:
convert -compress jpeg *.jpg my-jpegs.pdf
Remember to include the -compress jpeg
flag, or it'll store the images uncompressed and result in a massive PDF.
ImageMagick (via convert) requires Ghostscript (gs) to be installed in order to process PDFs I believe. Beware of memory issues if you are adding a lot of JPEGs at once.
As for your logical ordering, you can use ls
in combination with convert
to get the list in order.
Something along the lines of:
convert -compress jpeg `ls *.png` my-jpegs.pdf
See ls --help
for the various sorting options available.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With