I'm trying to merge images in JPG format with standard PDF documents, while keeping images in the same size. Earlier I was using ImageMagick's convert, but it results in huge quality drop since it converts everything into images, so I'm switching to ghostscript (or eventually itextpdf).
I found this code which inserts scaled image into A4 page:
gs \
-sDEVICE=pdfwrite \
-o foo.pdf \
/usr/local/share/ghostscript/8.71/lib/viewjpeg.ps \
-c \(my.jpg\) viewJPEG
PdfWriter from itextpdf in this way or that way could be alternative but it also adds an image into a page.
After inspecting ImageMagick's behavioral, I found out command it was using which I think is closest to my solution, but it doesn't seem to work when I'm trying to modify or use it. How should I modify it?
gs -q -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sDEVICE=pngalpha -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r72x72 -sOutputFile=out_gs.pdf fox_big.jpg