(none) imager-devel
/ help / lists / applications / search /
 

RE: Re: automatically finding format of 'data' type

From: rayg (
08739@xyz.molar.is)
Date: Mon 12 May 2003 - 15:43:47 GMT

  • Next message: Dan Muey: "using png format"

    my original message which received a 'pending' response follows at bottom.
    i used Benchmark to time two subroutines- one using
    Image::Size::imgsize(\$data), the other $img=Imager->new;
    $img->open(data=>$data, type=>$type); $img->getwidth; $img->getheight.

    On Mon, 12 May 2003, Dan Muey wrote:

    > I missed this thread and didn't see it in the archive.
    > Imager is 150 times faster than what? I'd also like to see
    > how to determine these things(x,y and typw)with Imager any copy or
    > link to this thread would be great. Thanks.

    original msg:

    i really want to use Imager, but i need to do:
      $img->open(data=>$data)
    without the explicit type definition since i only am given the image data
    in a buffer with no other knowledge. i currently use Image::Size to
    determine height, width, and type. but Imager is 150% faster and has a
    smaller memory footprint so i'd rather use it. it also has a feature i
    now really need to use- image scaling.

    so my question is: what is preventing automatic type detection from being
    added? i see the comment in Imager.pm:
      # FIXME: Find the format here if not specified
      # yes the code isn't here yet - next week maybe?
      # Next week? Are you high or something? That comment
      # has been there for half a year dude.
      # Look, i just work here, ok?

    but should it not be a simple matter of snipping a bit of code from
    Image::Size like the following bit?

    my %type_map = ( '^GIF8[7,9]a' => \&gifsize,
                     "^\xFF\xD8" => \&jpegsize,
                     "^\x89PNG\x0d\x0a\x1a\x0a" => \&pngsize,
                     "^P[1-7]" => \&ppmsize, # also XVpics
                     '\#define\s+\S+\s+\d+' => \&xbmsize,
                     '\/\* XPM \*\/' => \&xpmsize,
                     '^MM\x00\x2a' => \&tiffsize,
                     '^II\x2a\x00' => \&tiffsize,
                     '^BM' => \&bmpsize,
                     '^8BPS' => \&psdsize,
                     '^PCD_OPA' => \&pcdsize,
                     '^FWS' => \&swfsize,
                     "^\x8aMNG\x0d\x0a\x1a\x0a" => \&mngsize);

    thanks



  •