lorenzob has asked for the wisdom of the Perl Monks concerning the following question:

Hi Guys,

i'm creating some chart images with GD::Graph::bars3d using jpeg format and after that i create a pdf file attaching jpeg created, using PDF::Create module.

For some reason the Image can not be attached to my pdf with errore reported below

JPEG compression 49 not supported in PDF 1.2.

What't wrong with jpeg compression that keep PDF::Create complaint?

Many thanks Monks.

Replies are listed 'Best First'.
Re: GD::Graph::bars3d and PDF::Create
by zentara (Cardinal) on Jul 22, 2011 at 12:40 UTC
    An easier option would be to use a reliable image module like ImageMagick, Imager, or even GD itself, to read the compressed jpeg, and rewrite (save) it to an uncompressed jpeg. Then attach.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh

      Do you need mean this?

      $image = GD::Image->newFromJpegData($data, $truecolor) These methods will create an image from a JPEG file. They work just like newFromPng() and newFromPngData(), and will accept the same filehandle and pathname arguments. The optional $truecolor (0/1) value can be used to override the global setting of trueColor() to specify if the return image should be palette-based or truecolor. Bear in mind that JPEG is a 24-bit format, while GD is 8-bit. This means that photographic images will become posterized.

      Thanks

Re: GD::Graph::bars3d and PDF::Create
by Anonymous Monk on Jul 22, 2011 at 10:56 UTC

    What't wrong with jpeg compression that keep PDF::Create complaint?

    :D Its not supported? :P

    Maybe try attach a png or bitmap?

    I know, real helpful :)

    It probably means, PDF 1.2 (the PDF version you're trying to generate) doesn't support the type of JPG you're trying to attach, http://en.wikipedia.org/wiki/Portable_Document_Format#Raster_images mentions a little about this

    .`. _ _ __;_ \ /,//` --, `._) ( .oO( Ha ha ) '//,,, | )_/ /_|
Re: GD::Graph::bars3d and PDF::Create
by chrestomanci (Priest) on Jul 22, 2011 at 12:26 UTC

    An alternative approach that should look good if it works (I have not tried it), would be to get GD::Graph::bars3d to emit images in SVG vector format through the use of GD::SVG

    You can then convert the SVG file to pdf using inkscape's svg2pdf tool. If necessary you can join separate pdf files into one multi page document using pdftk

    Disclaimer: I have not tried to use GD::Graph::bars3d with GD::SVG, so I have no idea if it will work, but it it does then the results should be visually appealing, with a small file size.