I am trying to generate a thumbnail file for a PDF using Poppler. My naive solution looks like this:
`pdftoppm -jpeg -jpegopt "quality=80,progressive=y,optimize=y" -singlefile -scale-to #{size} #{input_filename} > #{output_filename}`
I'd like to mitigate command injection possibilities, which I know can be done by invoking system(cmd, *args)
but this doesn't play nicely with output redirection.
I've played around with Open3
but struggling to find an example online I can use as a starting point.
It turns out my main problem here was how I was dividing up options and their arguments. Each needs to be its own argument to Open3. The following works: