Using Image::Size.pm on system where I can't install modules using make 
Author Message
 Using Image::Size.pm on system where I can't install modules using make

Hi,

I have a need for the routines in Image::Size.pm but I am unable to install
it the normal way.  Besides getting another provider, would anyone know how I
could use the routines without installing them?

Absent that, would anyone know of any routines that would allow me to read
JPG's and GIF's that don't require installation?

Thanks,

Mark Thompson



Sat, 21 Jul 2001 03:00:00 GMT  
 Using Image::Size.pm on system where I can't install modules using make
: I have a need for the routines in Image::Size.pm but I am unable to install
: it the normal way.  Besides getting another provider, would anyone know how I
: could use the routines without installing them?

Take a look at the section of perlfaq8 entitled "how do I keep my own
module/library directory?"



Sat, 21 Jul 2001 03:00:00 GMT  
 Using Image::Size.pm on system where I can't install modules using make
[Posted and a courtesy copy mailed.]



Quote:
> I have a need for the routines in Image::Size.pm but I am unable to install
> it the normal way.  Besides getting another provider, would anyone know how I
> could use the routines without installing them?

Yes -- adapt the algorithms, as I did (see below).

Quote:
> Absent that, would anyone know of any routines that would allow me to read
> JPG's and GIF's that don't require installation?

Here is my code.  All you need to supply is your own function 'bin_read'
to read the image file and return the requested number of bytes on
each call or FALSE on failure.  Don't forget 'binmode' when you open the
file!  How you format and return the results is up to you, of course.

# Return formatted width and height; adapted from Image::Size.

sub do_GIF      {
    my ($x, $y) = unpack 'x6 v v' => bin_read(10);
    'GIF Image' . ($x && $y ? " $x × $y pixels" : "")

Quote:
}

sub do_JPEG     {
    my $JPEG         = 'JPEG Image';
    my $MARKER     = 0xFF;      # Section marker.
    my $SIZE_FIRST = 0xC0;      # Range of segment identifier codes
    my $SIZE_LAST  = 0xC3;      #  that hold size info.
    bin_read(2) or return $JPEG; # Skip header ID.
    while () {
        my ($marker, $code, $length) = unpack 'C C n' => bin_read(4);
        ($marker || "") eq $MARKER or return $JPEG; # Valid segment.
        last if $SIZE_FIRST <= $code && $code <= $SIZE_LAST;
        bin_read($length - 2) or return $JPEG; # Skip over data.
    }
    sprintf "$JPEG %s &times; %s pixels" => unpack 'v v' =>
        reverse bin_read(5);

Quote:
}

--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/



Sat, 21 Jul 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. using GD.pm for image re-size and annotation

2. using GD.pm for image re-size and annotation

3. Can't install Net module using ppm - Can't find module

4. Making an include using CGI.pm module

5. Can't get size value back when using $ftp->size

6. help installing image::size module

7. Problem using Image::Size

8. Problem using Image::Size on a webserver

9. CodeBase.pm - a Perl module to access XBASE files using Sequiter's CodeBase

10. Detection of system size using perl

11. question: making nice looking tables using CGI.pm ?

12. Can't locate URI::URL.pm in @INC using XML::Parser.pm

 

 
Powered by phpBB® Forum Software