in reply to Write to and read from scalar

Ahh, that's what I was after. Many thanks ;) However, I can't seem to get PDF::API2's image methods to accept the scalar data as input: $png = $pdf->image_png($file); I know my scalar contains a valid PNG image as I've written the source image to a scalar, closed the file handle, opened another and written the scalar back to disc and the file is a valid PNG. Any ideas on how to do this please? Thanks again.

Replies are listed 'Best First'.
Re^2: Write to and read from scalar
by Eliya (Vicar) on Mar 23, 2012 at 15:25 UTC
    $png = $pdf->image_png($file);

    As it looks, the underlying package PDF::API2::Resource::XObject::Image::PNG doesn't expect a (pre-opened) file handle, but a name of a file, which it goes to open itself.

    In case the functionality is important to you, you might want to try modifying the code yourself such that the open is done only in case $file isn't already a valid file handle (check with ref).