Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #3365 > unrolled thread
| Started by | Eli the Bearded <*@eli.users.panix.com> |
|---|---|
| First post | 2019-04-06 21:33 +0000 |
| Last post | 2019-06-16 07:11 -0700 |
| Articles | 14 — 10 participants |
Back to article view | Back to comp.lang.postscript
JPEG to PDF question Eli the Bearded <*@eli.users.panix.com> - 2019-04-06 21:33 +0000
Re: JPEG to PDF question John Forkosh <forkosh@panix.com> - 2019-04-07 06:39 +0000
Re: JPEG to PDF question Guy <guy@guysalias.tk.invalid> - 2019-04-07 14:52 -0500
Re: JPEG to PDF question Eli the Bearded <*@eli.users.panix.com> - 2019-04-07 21:54 +0000
Re: JPEG to PDF question ken <ken@spamcop.net> - 2019-04-08 10:30 +0100
Re: JPEG to PDF question Martin Leese <please@see.Web.for.e-mail.INVALID> - 2019-04-08 10:24 -0600
Re: JPEG to PDF question Javier <invalid@invalid.invalid> - 2019-04-10 18:10 -0500
Re: JPEG to PDF question luser droog <luser.droog@gmail.com> - 2019-04-10 18:01 -0700
Re: JPEG to PDF question ken <ken@spamcop.net> - 2019-04-11 10:50 +0100
Re: JPEG to PDF question Scott Hemphill <hemphill@hemphills.net> - 2019-04-11 17:59 -0400
Re: JPEG to PDF question luser droog <luser.droog@gmail.com> - 2019-04-11 16:03 -0700
Re: JPEG to PDF question Eli the Bearded <*@eli.users.panix.com> - 2019-04-12 00:33 +0000
Re: JPEG to PDF question Mark Carroll <mtbc@bcs.org> - 2019-04-12 07:15 +0100
Re: JPEG to PDF question orr721@gmail.com - 2019-06-16 07:11 -0700
| From | Eli the Bearded <*@eli.users.panix.com> |
|---|---|
| Date | 2019-04-06 21:33 +0000 |
| Subject | JPEG to PDF question |
| Message-ID | <eli$1904061719@qaz.wtf> |
For the task of submitting receipts to a web form that only accepts PDF files, I'd like to be able to easily turn JPEGs into PDF. Today I had one that I converted with Gimp, using "export as" -rw-rw-r-- 1 username username 585211 Apr 6 14:13 /tmp/statement.jpg -rw-rw-r-- 1 username username 5113015 Apr 6 14:14 /tmp/statement.pdf This worked, but it's not great. Besides the PDF requirement, there's also a file size cap which I just barely made it under (5MB: 5242880 bytes). It's easy to see how the next one might not fit in 5MB with that 8.7x file enlargement Gimp gave me. It looks like Gimp put a 1500x2000 JPEG as a 1500x2000 RGB bitmap with only flate compression. This is 8.7x larger than JPEG and only 1.7x smaller than raw binary RGB. What's a better way to do this? Unix (Linux) command line preferred. Gui (like Gimp) acceptable but not great. Bonus if it can create a multiple page PDF from individual images. Elijah ------ also acceptable convert to some other intermediate image format first
[toc] | [next] | [standalone]
| From | John Forkosh <forkosh@panix.com> |
|---|---|
| Date | 2019-04-07 06:39 +0000 |
| Message-ID | <q8c5uf$as5$1@reader2.panix.com> |
| In reply to | #3365 |
Eli the Bearded <*@eli.users.panix.com> wrote: > For the task of submitting receipts to a web form that only accepts PDF > files, I'd like to be able to easily turn JPEGs into PDF. Today I had > one that I converted with Gimp, using "export as" > > -rw-rw-r-- 1 username username 585211 Apr 6 14:13 /tmp/statement.jpg > -rw-rw-r-- 1 username username 5113015 Apr 6 14:14 /tmp/statement.pdf > > This worked, but it's not great. Besides the PDF requirement, there's > also a file size cap which I just barely made it under (5MB: 5242880 > bytes). It's easy to see how the next one might not fit in 5MB with that > 8.7x file enlargement Gimp gave me. > > It looks like Gimp put a 1500x2000 JPEG as a 1500x2000 RGB bitmap with > only flate compression. This is 8.7x larger than JPEG and only 1.7x > smaller than raw binary RGB. > > What's a better way to do this? Unix (Linux) command line preferred. Gui > (like Gimp) acceptable but not great. Bonus if it can create a multiple > page PDF from individual images. > > Elijah > ------ > also acceptable convert to some other intermediate image format first One Linux command line tool for jpg->pdf would be ImageMagick's convert convert anyfile.jpg anyfile.pdf No filesize cap (that I'm aware of), but can't say whether or not it's "better" with respect to your other problems. And it's probably one-to-one with respect to "multiple pages", but then pdfjam pdfjam pagenum*.pdf --outfile allpages.pdf will definitely do that. And check out both programs' manpages for numerous (and I do mean numerous) other -switches. -- John Forkosh ( mailto: j@f.com where j=john and f=forkosh )
[toc] | [prev] | [next] | [standalone]
| From | Guy <guy@guysalias.tk.invalid> |
|---|---|
| Date | 2019-04-07 14:52 -0500 |
| Message-ID | <AA2A973D375D4EAC2E284CEEC009E394A9D7@127.0.0.1> |
| In reply to | #3365 |
Eli the Bearded wrote: > I'd like to be able to easily turn JPEGs into PDF. > Can use viewjpeg.ps of Ghostscript distribution. gs -sDEVICE=pdfwrite -o out.pdf viewjpeg.ps -c (in.jpg)viewJPEG
[toc] | [prev] | [next] | [standalone]
| From | Eli the Bearded <*@eli.users.panix.com> |
|---|---|
| Date | 2019-04-07 21:54 +0000 |
| Message-ID | <eli$1904071723@qaz.wtf> |
| In reply to | #3367 |
Elsethread, John Forkosh suggested Imagemagick's convert. I did try that, should have mentioned. $ convert /tmp/statement.jpg /tmp/statement.pdf convert: not authorized `/tmp/statement.pdf' @ error/constitute.c/WriteImage/1028. $ ls -ld /tmp/statement.pdf ls: cannot access '/tmp/statement.pdf': No such file or directory $ convert --version Version: ImageMagick 6.8.9-9 Q16 x86_64 2018-09-28 http://www.imagemagick.org Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC Features: DPC Modules OpenMP Delegates: bzlib cairo djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png rsvg tiff wmf x xml zlib $ This is Ubuntu 16.04.6. All updates as of a week or two ago applied. In comp.lang.postscript, Guy <guy[AT]guysalias[DOT]tk> wrote: > Eli the Bearded wrote: >> I'd like to be able to easily turn JPEGs into PDF. > Can use viewjpeg.ps of Ghostscript distribution. > > gs -sDEVICE=pdfwrite -o out.pdf viewjpeg.ps -c (in.jpg)viewJPEG That works very well, thanks. $ gs -sDEVICE=pdfwrite -o/tmp/statement.pdf viewjpeg.ps -c '(/tmp/statement.jpg)viewJPEG' GPL Ghostscript 9.26 (2018-11-20) Copyright (C) 2018 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. $ ls -l /tmp/statement.* -rw-rw-r-- 1 username username 585211 Apr 6 14:13 /tmp/statement.jpg -rw-rw-r-- 1 username username 587845 Apr 7 14:26 /tmp/statement.pdf $ Elijah ------ wrote himself a wrapper script to remember this
[toc] | [prev] | [next] | [standalone]
| From | ken <ken@spamcop.net> |
|---|---|
| Date | 2019-04-08 10:30 +0100 |
| Message-ID | <MPG.3715250f8662497898989d@usenet.plus.net> |
| In reply to | #3368 |
In article <eli$1904071723@qaz.wtf>, *@eli.users.panix.com says... > In comp.lang.postscript, Guy <guy[AT]guysalias[DOT]tk> wrote: > > Eli the Bearded wrote: > >> I'd like to be able to easily turn JPEGs into PDF. > > Can use viewjpeg.ps of Ghostscript distribution. > > > > gs -sDEVICE=pdfwrite -o out.pdf viewjpeg.ps -c (in.jpg)viewJPEG > > That works very well, thanks. Just a quick caveat here, for anyone running into this by a web search. Older versions of Ghostscript do not have the 'JPEGPassThrough' option and so will do the same thing as your original Gimp setup; decompress the JPEG and then write it as an image. NB! Unless you take extra action with these older versions of Ghostscript, the image will be compressed again with DCT (JPEG), not with Flate. This will lead to additional loss of fidelity in the image samples. The commit which added the ability to pass JPEG images unchanged is (for the technically minded) here: http://git.ghostscript.com/? p=ghostpdl.git;a=commit;h=eb5d417375e1c7052aeb9f2532d34573bfd07f53 This is present in versions of Ghostscript starting at 9.23 though I seem to remember there were a couple of bug fixes, so I'd definitely advise using an up to date version if you want to do this (9.26 should be fine, since I see you are using that). Ken
[toc] | [prev] | [next] | [standalone]
| From | Martin Leese <please@see.Web.for.e-mail.INVALID> |
|---|---|
| Date | 2019-04-08 10:24 -0600 |
| Message-ID | <q8fsk2$kda$1@dont-email.me> |
| In reply to | #3368 |
Eli the Bearded wrote: > Elsethread, John Forkosh suggested Imagemagick's convert. I did try > that, should have mentioned. > > $ convert /tmp/statement.jpg /tmp/statement.pdf > convert: not authorized `/tmp/statement.pdf' @ error/constitute.c/WriteImage/1028. ImageMagick can write PDFs, but it is not built-in as standard. Use "identify -list format" to see what is built-in to your version. Mind you, if Ghostscript works for you then I would just use that. -- Regards, Martin Leese E-mail: please@see.Web.for.e-mail.INVALID Web: http://members.tripod.com/martin_leese/
[toc] | [prev] | [next] | [standalone]
| From | Javier <invalid@invalid.invalid> |
|---|---|
| Date | 2019-04-10 18:10 -0500 |
| Message-ID | <jLKdnc8pqJd26jPBnZ2dnUU78UnNnZ2d@brightview.co.uk> |
| In reply to | #3368 |
> $ convert /tmp/statement.jpg /tmp/statement.pdf > convert: not authorized `/tmp/statement.pdf' @ error/constitute.c/WriteImage/1028. https://github.com/pts/sam2p is a good alternative to imagemagick's convert. 'sam2p image.jpg image.pdf' works fine for me. >> gs -sDEVICE=pdfwrite -o out.pdf viewjpeg.ps -c '(in.jpg)viewJPEG' The -c and -o options do not appear in the manpage gs(1). Are the options documented somewhere else?
[toc] | [prev] | [next] | [standalone]
| From | luser droog <luser.droog@gmail.com> |
|---|---|
| Date | 2019-04-10 18:01 -0700 |
| Message-ID | <4e10f56d-1b4e-4329-92c2-e4d184c4648c@googlegroups.com> |
| In reply to | #3371 |
On Wednesday, April 10, 2019 at 6:10:36 PM UTC-5, Javier wrote: > > $ convert /tmp/statement.jpg /tmp/statement.pdf > > convert: not authorized `/tmp/statement.pdf' @ error/constitute.c/WriteImage/1028. > > https://github.com/pts/sam2p is a good alternative to imagemagick's > convert. 'sam2p image.jpg image.pdf' works fine for me. > > >> gs -sDEVICE=pdfwrite -o out.pdf viewjpeg.ps -c '(in.jpg)viewJPEG' > > The -c and -o options do not appear in the manpage gs(1). > Are the options documented somewhere else? -o is a shorthand for -sOutputFile= -c is for executing PS code. It runs after after any files mentioned before it. In this case it calls a function defined in viewjpeg.ps.
[toc] | [prev] | [next] | [standalone]
| From | ken <ken@spamcop.net> |
|---|---|
| Date | 2019-04-11 10:50 +0100 |
| Message-ID | <MPG.37191e5d8e4209a698989e@usenet.plus.net> |
| In reply to | #3371 |
In article <jLKdnc8pqJd26jPBnZ2dnUU78UnNnZ2d@brightview.co.uk>, invalid@invalid.invalid says... > > > $ convert /tmp/statement.jpg /tmp/statement.pdf > > convert: not authorized `/tmp/statement.pdf' @ error/constitute.c/WriteImage/1028. > > https://github.com/pts/sam2p is a good alternative to imagemagick's > convert. 'sam2p image.jpg image.pdf' works fine for me. > > >> gs -sDEVICE=pdfwrite -o out.pdf viewjpeg.ps -c '(in.jpg)viewJPEG' > > The -c and -o options do not appear in the manpage gs(1). > Are the options documented somewhere else? Yes, in the extensive Ghostscript documentation :-) The documentation is all in HTML and can usually be found in the Ghostscript install folder under 'doc' or failing that here: https://www.ghostscript.com/doc/9.27/Readme.htm -o is documented in this section of use.htm: https://www.ghostscript.com/doc/9.27/Use.htm#File_output -c is documneted in the same HTML file: https://www.ghostscript.com/doc/9.27/Use.htm#General_switches The man pages aren't supplied by the Ghostscript development team, no idea who is supplying that, possibly the package maintainer on your distribution. Ken
[toc] | [prev] | [next] | [standalone]
| From | Scott Hemphill <hemphill@hemphills.net> |
|---|---|
| Date | 2019-04-11 17:59 -0400 |
| Message-ID | <87d0lsfbjr.fsf@hemphills.net> |
| In reply to | #3367 |
Guy <guy@guysalias.tk.invalid> writes: > Eli the Bearded wrote: > >> I'd like to be able to easily turn JPEGs into PDF. >> > > > Can use viewjpeg.ps of Ghostscript distribution. > > gs -sDEVICE=pdfwrite -o out.pdf viewjpeg.ps -c (in.jpg)viewJPEG You can also use netpbm tools, along with Ghostscript's ps2pdf: djpeg in.jpg | pnmtops | ps2pdf - out.pdf In my CentOS distribution, djpeg is from libjpeg-turbo-utils, pnmtops is from netpbm-progs, and ps2pdf was already installed from ghostscript. Scott -- Scott Hemphill hemphill@alumni.caltech.edu "This isn't flying. This is falling, with style." -- Buzz Lightyear
[toc] | [prev] | [next] | [standalone]
| From | luser droog <luser.droog@gmail.com> |
|---|---|
| Date | 2019-04-11 16:03 -0700 |
| Message-ID | <6fb8b5d1-b656-4b50-8341-d599d0a2607e@googlegroups.com> |
| In reply to | #3374 |
On Thursday, April 11, 2019 at 4:59:41 PM UTC-5, Scott Hemphill wrote: > Guy <guy@guysalias.tk.invalid> writes: > > > Eli the Bearded wrote: > > > >> I'd like to be able to easily turn JPEGs into PDF. > >> > > > > > > Can use viewjpeg.ps of Ghostscript distribution. > > > > gs -sDEVICE=pdfwrite -o out.pdf viewjpeg.ps -c (in.jpg)viewJPEG > > You can also use netpbm tools, along with Ghostscript's ps2pdf: > > djpeg in.jpg | pnmtops | ps2pdf - out.pdf > > In my CentOS distribution, djpeg is from libjpeg-turbo-utils, > pnmtops is from netpbm-progs, and ps2pdf was already installed from > ghostscript. > This does indeed perform the conversion, but I think it will decompress and recompress which may be lossy AFAIUI.
[toc] | [prev] | [next] | [standalone]
| From | Eli the Bearded <*@eli.users.panix.com> |
|---|---|
| Date | 2019-04-12 00:33 +0000 |
| Message-ID | <eli$1904112032@qaz.wtf> |
| In reply to | #3374 |
In comp.lang.postscript, Scott Hemphill <hemphill@alumni.caltech.edu> wrote: > You can also use netpbm tools, along with Ghostscript's ps2pdf: > > djpeg in.jpg | pnmtops | ps2pdf - out.pdf > > In my CentOS distribution, djpeg is from libjpeg-turbo-utils, > pnmtops is from netpbm-progs, and ps2pdf was already installed from > ghostscript. Hmmm. I have all of those installed, but I deleted the statement.jpg I was using for the previous testing. Using a different JPEG from my temp directory I see: 81K JPEG -> djpeg -> 958K PPM (binary encoded raw bitmap) 958K PPM -> pnmtops -> 2.0M PS (ascii encoded raw bitmap) 2.0M PS -> ps2pdf -> 41K PDF (embedded binary JPEG) And the PS has the image rotated ninety degrees counter-clockwise (which, naturally, remains turned in the PDF). The image in this case was landscape format, and is now portrait format. My statement.jpg had been portrait oriented to begin with. The PDF has a lot of JPEG artifacts. I'd probably want to check the output carefully if using this for submitting photos of documents through web portals. Elijah ------ didn't see any options for selecting JPEG compression
[toc] | [prev] | [next] | [standalone]
| From | Mark Carroll <mtbc@bcs.org> |
|---|---|
| Date | 2019-04-12 07:15 +0100 |
| Message-ID | <87bm1blpf3.fsf@ixod.org> |
| In reply to | #3376 |
On 12 Apr 2019, Eli the Bearded wrote: (snpi) > 81K JPEG -> djpeg -> 958K PPM (binary encoded raw bitmap) > 958K PPM -> pnmtops -> 2.0M PS (ascii encoded raw bitmap) > 2.0M PS -> ps2pdf -> 41K PDF (embedded binary JPEG) > > And the PS has the image rotated ninety degrees counter-clockwise > (which, naturally, remains turned in the PDF). The image in this case > was landscape format, and is now portrait format. My statement.jpg had > been portrait oriented to begin with. pnmtops has a -noturn option. > The PDF has a lot of JPEG artifacts. I'd probably want to check the > output carefully if using this for submitting photos of documents > through web portals. ps2pdf has a -dPDFSETTINGS=/prepress option which can help. -- Mark
[toc] | [prev] | [next] | [standalone]
| From | orr721@gmail.com |
|---|---|
| Date | 2019-06-16 07:11 -0700 |
| Message-ID | <11a552c7-00b6-4866-9051-a4fe47ddbaa6@googlegroups.com> |
| In reply to | #3365 |
you need sam2p. it embeds many image formats into pdf with no recompression. works on mac/linux/windows command line. https://github.com/pts/sam2p --- Dňa sobota, 6. apríla 2019 23:33:25 UTC+2 Eli the Bearded napísal(-a): > For the task of submitting receipts to a web form that only accepts PDF > files, I'd like to be able to easily turn JPEGs into PDF. Today I had > one that I converted with Gimp, using "export as" > > -rw-rw-r-- 1 username username 585211 Apr 6 14:13 /tmp/statement.jpg > -rw-rw-r-- 1 username username 5113015 Apr 6 14:14 /tmp/statement.pdf > > This worked, but it's not great. Besides the PDF requirement, there's > also a file size cap which I just barely made it under (5MB: 5242880 > bytes). It's easy to see how the next one might not fit in 5MB with that > 8.7x file enlargement Gimp gave me. > > It looks like Gimp put a 1500x2000 JPEG as a 1500x2000 RGB bitmap with > only flate compression. This is 8.7x larger than JPEG and only 1.7x > smaller than raw binary RGB. > > What's a better way to do this? Unix (Linux) command line preferred. Gui > (like Gimp) acceptable but not great. Bonus if it can create a multiple > page PDF from individual images. > > Elijah > ------ > also acceptable convert to some other intermediate image format first Dňa sobota, 6. apríla 2019 23:33:25 UTC+2 Eli the Bearded napísal(-a): > For the task of submitting receipts to a web form that only accepts PDF > files, I'd like to be able to easily turn JPEGs into PDF. Today I had > one that I converted with Gimp, using "export as" > > -rw-rw-r-- 1 username username 585211 Apr 6 14:13 /tmp/statement.jpg > -rw-rw-r-- 1 username username 5113015 Apr 6 14:14 /tmp/statement.pdf > > This worked, but it's not great. Besides the PDF requirement, there's > also a file size cap which I just barely made it under (5MB: 5242880 > bytes). It's easy to see how the next one might not fit in 5MB with that > 8.7x file enlargement Gimp gave me. > > It looks like Gimp put a 1500x2000 JPEG as a 1500x2000 RGB bitmap with > only flate compression. This is 8.7x larger than JPEG and only 1.7x > smaller than raw binary RGB. > > What's a better way to do this? Unix (Linux) command line preferred. Gui > (like Gimp) acceptable but not great. Bonus if it can create a multiple > page PDF from individual images. > > Elijah > ------ > also acceptable convert to some other intermediate image format first Dňa sobota, 6. apríla 2019 23:33:25 UTC+2 Eli the Bearded napísal(-a): > For the task of submitting receipts to a web form that only accepts PDF > files, I'd like to be able to easily turn JPEGs into PDF. Today I had > one that I converted with Gimp, using "export as" > > -rw-rw-r-- 1 username username 585211 Apr 6 14:13 /tmp/statement.jpg > -rw-rw-r-- 1 username username 5113015 Apr 6 14:14 /tmp/statement.pdf > > This worked, but it's not great. Besides the PDF requirement, there's > also a file size cap which I just barely made it under (5MB: 5242880 > bytes). It's easy to see how the next one might not fit in 5MB with that > 8.7x file enlargement Gimp gave me. > > It looks like Gimp put a 1500x2000 JPEG as a 1500x2000 RGB bitmap with > only flate compression. This is 8.7x larger than JPEG and only 1.7x > smaller than raw binary RGB. > > What's a better way to do this? Unix (Linux) command line preferred. Gui > (like Gimp) acceptable but not great. Bonus if it can create a multiple > page PDF from individual images. > > Elijah > ------ > also acceptable convert to some other intermediate image format first
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.postscript
csiph-web