Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 1614  / 3 Years ago, fri, august 6, 2021, 9:07:58

I'm still learning the command line, and I'm having trouble piping a list of files into graphicsmagick for conversion to pdf:



find . -type f | sort | gm convert file.pdf


This gives the error: gm convert: Request did not return an image.



Can I do this without resorting to more complicated methods?


More From » pipe

 Answers
3

This is an old question, but I found it looking for a solution to the same problem and never really found a complete answer. I came up with a simple(-ish) way of doing it myself:



gm convert $(find . -type f -printf '%p0' | sort -z | sed 's/x00/ /g') file.pdf


It won't work if there are spaces or new lines in any of the original files' paths, though.



This method has to execute convert once for every input file. It takes much (much much) longer, especially if there are a large number of original images, but it won't get tripped up by file names:



find . -type f -printf '%p0' | sort -z | xargs -0 -I {} gm convert -adjoin file.pdf {} file.pdf

[#26191] Sunday, August 8, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ingsta

Total Points: 391
Total Questions: 103
Total Answers: 124

Location: Bonaire
Member since Wed, Mar 29, 2023
1 Year ago
ingsta questions
Sun, Oct 23, 22, 01:42, 2 Years ago
Sat, Oct 30, 21, 11:27, 3 Years ago
Sun, Nov 28, 21, 12:49, 2 Years ago
;