perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Barbar <dbar...@legato.com>
Subject RE: Generating images on-the-fly (newbie question)
Date Mon, 14 Oct 2002 18:13:38 GMT
Wim et all,

	Thanks for your input. I made the test, but somehow it didn't work.
I created index.epl and img.epl as shown below. My server has
HTML-Embperl-1.3.4, apache_1.3.26 and mod_perl-1.27.
	Surprisingly enough, with the code in img.epl I can copy test.png
into test_out.png (see img.epl). However, the resulting page in the browser,
when one loads index.epl, shows only the icon of an incorrect image (I made
sure "[-" were the first characters in the first line of img.epl).
	Another note, I had to comment out the line "binmode OUT",
otherwise, the file test_out.png was created empty, and I would get a "Can't
locate object method" error in the Embperl log (shown below as well).
	Is the content type "image/png" wrong? For what I could find, that
seemed correct. Am I missing something? Any other ideas? Thanks again for
your assistance. Best regards,

---
Daniel Barbar

index.epl:
----------
<html>
<head><title>TEST</title></head>
<body>
The image should come here: <br>
<img src="img.epl?arg=value">
</body
</html>

img.epl:
--------
[-
$http_headers_out{'Content-Type'} = "image/png";

$from = "test.png";
$to = "test_out.png";
open(FROM, "$from") or exit 1;
open(TO, ">$to") or exit 1;

#binmode OUT;
binmode TO;
while ($line = \<FROM>) {
    print TO $line;
    print OUT $line;
}
close(FROM);
close(TO);
exit;
-]

/tmp/embperl.log:
-----------------
[768]ERR:  24:  Error in Perl code: Can't locate object method "BINMODE" via
package "HTML::Embperl::Out" (perhaps you forgot
to load "HTML::Embperl::Out"?) at /usr/local/apache/htdocs/test/img.epl line
10.
[768]PERF: input = /usr/local/apache/htdocs/test/img.epl
[768]PERF: Time: 0 ms Evals: 1 Cache Hits: 0 (0%)
[768]Request finished. Mon Oct 14 10:20:56 2002
. Entry-SVs: 32010 -OBJs: 29 Exit-SVs: 32023 -OBJs: 28
[768]MEM: Free buffer for /usr/local/apache/htdocs/test/img.epl in
HTML::Embperl::DOC::_5
[768]CUP:  Error while closing HTML::Embperl::DOC::_5::OUT: Can't locate
object method "CLOSE" via package "HTML::Embperl::Out
" (perhaps you forgot to load "HTML::Embperl::Out"?) at
/usr/lib/perl5/site_perl/5.6.1/i586-linux/HTML/Embperl.pm line 1447.


-----Original Message-----
From: Wim Kerkhoff [mailto:wim@nyetwork.org]
Sent: Wednesday, October 09, 2002 5:31 PM
To: 'Daniel Barbar'; embperl@perl.apache.org
Subject: RE: Generating images on-the-fly (newbie question)


Daniel, 

You should be able to do something like this. I haven't tested this
example,
but I've done this before on code I no longer have access too.

In your page: <img src="me.html?your=params&go=here">

In me.html, have a block of Emberl like the following. The first [ will
have to be
the very first character. Otherwise, any whitespace inbetween will
become part of the image
which will corrupt it. 

[- 
$http_headers_out{'Content-Type'} = "image/gif";

$gifdata = .... ; # GD generated image

binmode OUT;
print OUT $gifdata;

exit;
-]



> Is there a way, using Embperl, to send the image back to the browser 
> on-the-fly, that is, without having to save it on a file first? 
> Something along the lines of (if you'd allow me to write such
aberration):
> <img src=[- print OUT $gd->png -]> 
>
> I'm aware that the code above isn't HTML, but perhaps it served the 
> purpose of clarifying what I want to do. Thanks in advance for your
help,

Mime
View raw message