You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Joachim Zobel <nc...@netcologne.de> on 2003/04/28 20:42:50 UTC

Image::Size and Location

Hi.

I would like to use Image::Size based on a Location instead of using it
on a file. Is there a way to do URI trans. (and may be content
negotiation) without doing a subrequest? What is the best way to do
this, if not?

Thanx,
Joachim

-- 
"... ein Geschlecht erfinderischer Zwerge, die fuer alles gemietet
werden 
koennen."                            - Bertolt Brecht - Leben des
Galilei 


Re: Image::Size and Location

Posted by "Randy J. Ray" <rj...@tellme.com>.
> I would like to use Image::Size based on a Location instead of using it
> on a file. Is there a way to do URI trans. (and may be content
> negotiation) without doing a subrequest? What is the best way to do
> this, if not?

(A better first step would have been to write me at the maintainer address in 
the documentation. Luckily, I read this list as well. :-)

The main reason that I've never put anything like this directly into the API 
is that the specification of things like the document root differ across 
different http servers. And even under Apache, the ultimate path can be 
affected by aliases, rewrite rules, etc.

My recommendation to users under mod_perl is to use the sub-request mechanism. 
Citing from the Apache(1) manpage:

SUB REQUESTS
        Apache provides a sub-request mechanism to lookup a uri or
        filename, performing all access checks, etc., without
        actually running the response phase of the given request.
        Notice, we have dropped the "sub_req_" prefix here.  The
        "request_rec*" returned by the lookup methods is blessed
        into the Apache::SubRequest class.  This way,
        "destroy_sub_request()" is called automatically during
        "Apache::SubRequest->DESTROY" when the object goes out of
        scope.  The Apache::SubRequest class inherits all the
        methods from the Apache class.

        $r->lookup_uri($uri)
               my $subr = $r->lookup_uri($uri);
               my $filename = $subr->filename;

               unless(-e $filename) {
                   warn "can't stat $filename!\n";
               }

        $r->lookup_file($filename)
               my $subr = $r->lookup_file($filename);

(Which of the two you use would depend on your circumstances.)

Hope this helps.

Randy
-- 
-------------------------------------------------------------------------------
Randy J. Ray     | Men occasionally stumble over the truth, but most of them
rjray@tellme.com | pick themselves up and hurry off as if nothing had happened.
+1 650 930-9097  |   -- Sir Winston Churchill