Re: Change JPG images to fit into an A4 PDF page

Sebastian Krause <[email protected]>
Newsgroups gmane.comp.video.image-magick.user
Message-ID <[email protected]>
Anthony Thyssen <[email protected]> wrote:
> I have added this to the notes in IM examples, File Formats, PDF
>   http://www.imagemagick.org/Usage/formats/#pdf_alturnatives
>
> Question can that perl script 'fix' a PDF that IM generated, or is it
> restricted to PDF's created by sam2p??

Unfortunately it doesn't work with default PDFs created by IM, you
get the following error:

$ sam2p_pdf_scale.pl 595 842 test.pdf
sam2p PDF syntax error (no cm)

Now I'm not really familiar with the internal file structure of PDF,
but the beginning of a 640x400 PNG converted by sam2p looks like
this:

,----
| %PDF-1.2
| %Çì<8f>¢
| 2 0 obj
| <</Type/Pages/Kids[4 0 R]/Count 1>>
| endobj
| 3 0 obj
| <</Length 1565>>
| stream
| q
| 640 0 0 400 0 0 cm
| BI/Interpolate false/W 640/H 400/CS/DeviceGray /BPC 8/F/Fl ID
| [...]
`----

The second to last line is what the script is looking for:

,----[ sam2p_pdf_scale.pl ]
| die "sam2p PDF syntax error (no cm)\n" if $S!~m@\n((\d+) 0 0 (\d+) 0 0 cm\b)@g;
`----

Now if we could somehow tell IM to store the units this way, the
script might work on those PDFs as well.

Sebastian

_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.