yoz-y has asked for the wisdom of the Perl Monks concerning the following question:

so, i'm trying to create a forum signature with imagemagick. Until now all worked well but i'm blocked on one problem.

The thing is I need to get an image from an url and assemble it with already created background.

LWP::Simple 's 'get' will read the image to a scalar variable but then I don't know how to handle it using imagemagick (which reads images from files, and thus accepts filehandles as identifiers).

2006-04-17 Retitled by planetscape, as per Monastery guidelines: one-word (or module-only) titles pose a hazard to site navigation
Original title: 'imagemagick'

Replies are listed 'Best First'.
Re: reading image blob w/Image::Magick
by davido (Cardinal) on Apr 16, 2006 at 20:45 UTC

    If it's really the case that Image::Magick will only accept data from filehandles, you can open a scalar variable as though it were an in-memory file:

    open IMAGEHANDLE, '<', \$image or die $!;

    Dave

Re: reading image blob w/Image::Magick
by salva (Canon) on Apr 16, 2006 at 21:24 UTC
Re: reading image blob w/Image::Magick
by davidrw (Prior) on Apr 16, 2006 at 21:16 UTC
    The PerlMagick docs have a 'Working with Blobs' section -- there are ImageToBlob() and BlobToImage() methods ..

    Also, you could use IO::Scalar to create a filehandle for the string and pass that to Image::Magick
      the objects provided by modules like IO::Scalar are not backed by real file descriptors at the OS level, and so, they can not be passed to C functions requiring open files as arguments (unless those functions have been modified to use PerlIO, but this is quite rare).
        Image::Magick can read from perl filehandles though:
        $image = Image::Magick->new; open(IMAGE, 'image.gif'); $image->Read(file=>\*IMAGE); close(IMAGE);
        despite that, IO::Scalar wouldn't work?
Re: reading image blob w/Image::Magick
by rhesa (Vicar) on Apr 16, 2006 at 22:05 UTC
    As an alternative to the solutions with blobs, you could use LWP::Simple's getstore($url, $file) function instead, then pass the file to ImageMagick.