September 3rd, 2009
Bash magic: convert a high-res PNG to a small PDF with convert and sam2p
sam2p doesn’t like taking a lot of PNGs exported from Inkscape as straight input. This works around that issue by using ImageMagick convert it to an RGB (not RGBA) PNM before piping it into sam2p:
convert ${input_file} -colorspace RGB pnm:- | sam2p -c:lzw -m:dpi:$(echo "scale=5;72*(72/${dpi})" | bc) - PDF:${output_file}
Yes, the strange DPI syntax is needed. Yes, it’s totally counter-intuitive and I’d love to know why it works that way.

