[27846] in Perl-Users-Digest
Perl-Users Digest, Issue: 9210 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 29 03:05:55 2006
Date: Sat, 29 Apr 2006 00:05:03 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 29 Apr 2006 Volume: 10 Number: 9210
Today's topics:
Re: How to display image from RAM with some text around <no@email.com>
Re: How to display image from RAM with some text around xhoster@gmail.com
Re: How to display image from RAM with some text around xhoster@gmail.com
new CPAN modules at Sat Apr 29 2006 (Randal Schwartz)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 28 Apr 2006 19:05:51 +0100
From: Brian Wakem <no@email.com>
Subject: Re: How to display image from RAM with some text around
Message-Id: <4bf3rvF111004U1@individual.net>
Asterbing wrote:
> Hello,
>
> I would like to display a serial of tiny images (as the one here in $img
> of 55 bytes) from RAM, without to go through any temporary disk file
> (unless if possible to create a ramdisk with some lines of Perl ;-)).
> So, I've tried this :
>
> #!/usr/bin/perl -T
> use strict;
> use warnings;
>
> my $img = pack("C*", 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x08, 0x00,
> 0x08, 0x00, 0x91, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xA6, 0xCA, 0xF0, 0x2A,
> 0x5F, 0xFF, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
> 0x08, 0x00, 0x00, 0x02, 0x10, 0x8C, 0x7F, 0xA2, 0x3B, 0xB1, 0xEC, 0x9E,
> 0x68, 0x72, 0xC6, 0x47, 0x65, 0x1B, 0xBC, 0x8F, 0x02, 0x00, 0x3B);
>
> print "Content-type: text/html\n\n";
> print "<p>This is an image :</p>";
> print $img;
> print "<p>That's all !</p>";
> exit 0;
>
> If I remove the "... This is an image ..." line, the image is well shown
> in browser, but the last line of text is ignored.
>
> If I let the "... This is an image ..." line, I get the sentence,
> then the image content as text and the last line "That's all".
>
> Maybe ideal would be to go through something like "print <img
> src="display_image_value.cgi"></img>"; with POSted image (while
> impossible to pass image data through GET in url itself), but how to
> "simulate" a POST without any form and its action ?
>
> Am I on the wrong way(s) ? How to do ?
An html page does not contain image data, it contains urls of images, which
your browser then fetches.
You can indeed use <img src="myimage.cgi"> where myimage.cgi prints your
image data, but you must print the correct header first.
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: 28 Apr 2006 18:25:16 GMT
From: xhoster@gmail.com
Subject: Re: How to display image from RAM with some text around
Message-Id: <20060428144018.934$LV@newsreader.com>
Asterbing <no@thanks.com> wrote:
> Hello,
>
> I would like to display a serial of tiny images (as the one here in $img
> of 55 bytes) from RAM, without to go through any temporary disk file
> (unless if possible to create a ramdisk with some lines of Perl ;-)).
> So, I've tried this :
>
> #!/usr/bin/perl -T
> use strict;
> use warnings;
>
> my $img = pack("C*", 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x08, 0x00,
> 0x08, 0x00, 0x91, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xA6, 0xCA, 0xF0, 0x2A,
> 0x5F, 0xFF, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
> 0x08, 0x00, 0x00, 0x02, 0x10, 0x8C, 0x7F, 0xA2, 0x3B, 0xB1, 0xEC, 0x9E,
> 0x68, 0x72, 0xC6, 0x47, 0x65, 0x1B, 0xBC, 0x8F, 0x02, 0x00, 0x3B);
>
> print "Content-type: text/html\n\n";
> print "<p>This is an image :</p>";
> print $img;
> print "<p>That's all !</p>";
> exit 0;
>
> If I remove the "... This is an image ..." line, the image is well shown
> in browser,
If you use an actual web-browser, the image is not shown, because you
explictly told it you were sending html, not an image. If you use IE, it
might be shown as an image. But then again, IE might do just about
anything.
> but the last line of text is ignored.
Like I said, IE might do just about anything.
>
> If I let the "... This is an image ..." line, I get the sentence,
> then the image content as text and the last line "That's all".
>
> Maybe ideal would be to go through something like "print <img
> src="display_image_value.cgi"></img>"; with POSted image (while
> impossible to pass image data through GET in url itself)
It is possible to pass image data through GET if you encode it first.
> Am I on the wrong way(s) ? How to do ?
You could use the data uri, but it doesn't work with IE.
my $png = get_image_binary_somehow();
my $u=URI->new("data:");
$u->media_type("image/png");
$u->data($png);
print qq{<img src="$u" alt="Use Fire Fox (or other RFC 2397 compliant
browser) to see images">};
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 28 Apr 2006 19:37:04 GMT
From: xhoster@gmail.com
Subject: Re: How to display image from RAM with some text around
Message-Id: <20060428155207.322$0n@newsreader.com>
xhoster@gmail.com wrote:
> >
> > Maybe ideal would be to go through something like "print <img
> > src="display_image_value.cgi"></img>"; with POSted image (while
> > impossible to pass image data through GET in url itself)
>
> It is possible to pass image data through GET if you encode it first.
>
> > Am I on the wrong way(s) ? How to do ?
>
> You could use the data uri, but it doesn't work with IE.
>
> my $png = get_image_binary_somehow();
> my $u=URI->new("data:");
> $u->media_type("image/png");
> $u->data($png);
> print qq{<img src="$u" alt="Use Fire Fox (or other RFC 2397 compliant
> browser) to see images">};
Following up to myself here. I hacked up a cgi which will render the
inline image data for you, so it works (with some mods) on non RFC 2397
browsers. It requires a round trip to the server for each image, but
the server doesn't need to persist the data to be rendered, as the client
provided it each time.
This auxillary cgi needs to be in runnable:
$ cat exploder_render.cgi
#!/usr/bin/perl -T
use strict;
use warnings;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use URI;
## This script allows you to use the data URI method (with some modifications)
## in browsers that do not support data URI
my $u = new URI CGI::param('data');
print CGI::header($u->media_type);
print $u->data;
Now you do this:
> cat image_test.cgi
#!/usr/bin/perl -T
use strict;
use warnings;
use URI;
use URI::Escape;
my $img = pack("C*", 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x08, 0x00,
0x08, 0x00, 0x91, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xA6, 0xCA, 0xF0, 0x2A,
0x5F, 0xFF, 0x00, 0x00, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
0x08, 0x00, 0x00, 0x02, 0x10, 0x8C, 0x7F, 0xA2, 0x3B, 0xB1, 0xEC, 0x9E,
0x68, 0x72, 0xC6, 0x47, 0x65, 0x1B, 0xBC, 0x8F, 0x02, 0x00, 0x3B);
print "Content-type: text/html\n\n";
my $u=URI->new("data:");
$u->media_type("image/png");
$u->data($img);
## works only on RFC2397
print qq{<img src="$u" alt="Use Fire Fox (or other RFC 2397 compliant
browser) to see images">};
print "<hr>";
## works everywhere, at the expense of a server trip per image.
my $new_u = "exploder_render.cgi?data=". uri_escape($u);
print qq{<img src="$new_u" alt="should work on any browser">};
print "<p>That's all !</p>";
exit 0;
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Sat, 29 Apr 2006 04:42:05 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules at Sat Apr 29 2006
Message-Id: <IyGvq5.8yF@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
HTML-Template-Compiled-0.63
http://search.cpan.org/~tinita/HTML-Template-Compiled-0.63/
Template System Compiles HTML::Template files to Perl code
----
NetAddr-IP-Lite-0.04
http://search.cpan.org/~miker/NetAddr-IP-Lite-0.04/
Manages IPv4 and IPv6 addresses and subnets
----
NetAddr-IP-Lite-0.03
http://search.cpan.org/~miker/NetAddr-IP-Lite-0.03/
Manages IPv4 and IPv6 addresses and subnets
----
App-SimpleScan-1.05
http://search.cpan.org/~mcmahon/App-SimpleScan-1.05/
simple_scan's core code
----
Net-DNSBL-MultiDaemon-0.16
http://search.cpan.org/~miker/Net-DNSBL-MultiDaemon-0.16/
multiple DNSBL emulator
----
NetAddr-IP-Lite-0.02
http://search.cpan.org/~miker/NetAddr-IP-Lite-0.02/
Manages IPv4 and IPv6 addresses and subnets
----
WWW-Myspace-0.44
http://search.cpan.org/~grantg/WWW-Myspace-0.44/
Access MySpace.com profile information from Perl
----
Class-DBI-AutoIncrement-0.02
http://search.cpan.org/~erwan/Class-DBI-AutoIncrement-0.02/
Emulate auto-incrementing columns on Class::DBI subclasses
----
Time-TAI64-2.11
http://search.cpan.org/~joval/Time-TAI64-2.11/
Perl extension for converting TAI64 strings into standard unix timestamps.
----
HTTP-Proxy-0.19
http://search.cpan.org/~book/HTTP-Proxy-0.19/
A pure Perl HTTP proxy
----
Module-Mask-Deps-0.02
http://search.cpan.org/~mattlaw/Module-Mask-Deps-0.02/
Mask modules not listed as dependencies
----
Module-Mask-0.02
http://search.cpan.org/~mattlaw/Module-Mask-0.02/
Pretend certain modules are not installed
----
Module-Util-1.01
http://search.cpan.org/~mattlaw/Module-Util-1.01/
Module name tools and transformations
----
onsearch-0.99
http://search.cpan.org/~rkies/onsearch-0.99/
----
FastSearch-1.0
http://search.cpan.org/~rkies/FastSearch-1.0/
Fast string search library.
----
Net-Scan-HTTP-Server-Version-0.02
http://search.cpan.org/~mcantoni/Net-Scan-HTTP-Server-Version-0.02/
grab HTTP server version
----
Statistics-Gap-0.09
http://search.cpan.org/~anaghakk/Statistics-Gap-0.09/
An adaptation of the "Gap Statistic"
----
Class-DBI-AutoIncrement-0.01
http://search.cpan.org/~erwan/Class-DBI-AutoIncrement-0.01/
Emulate auto-incrementing columns in a Class::DBI table
----
Class-STL-Containers-0.18
http://search.cpan.org/~gaffie/Class-STL-Containers-0.18/
Perl extension for STL-like object management
----
Catalyst-Plugin-ClamAV-0.01
http://search.cpan.org/~fujiwara/Catalyst-Plugin-ClamAV-0.01/
ClamAV scanning Plugin for Catalyst
----
DBM-Deep-0.99_02
http://search.cpan.org/~rkinyon/DBM-Deep-0.99_02/
A pure perl multi-level hash/array DBM
----
Sub-Exporter-0.95
http://search.cpan.org/~rjbs/Sub-Exporter-0.95/
a sophisticated exporter for custom-built routines
----
CGI-Persist-2.4
http://search.cpan.org/~sinister/CGI-Persist-2.4/
Web persistency made usable.
----
Module-Build-Kwalitee-0.21
http://search.cpan.org/~stig/Module-Build-Kwalitee-0.21/
Module::Build subclass with prepackaged tests
----
HTML-Parser-3.54
http://search.cpan.org/~gaas/HTML-Parser-3.54/
HTML parser class
----
Plagger-0.6.5
http://search.cpan.org/~miyagawa/Plagger-0.6.5/
Pluggable RSS/Atom Aggregator
----
MP3-Find-0.05
http://search.cpan.org/~peichman/MP3-Find-0.05/
Search and sort MP3 files based on their ID3 tags
----
Math-Symbolic-0.502
http://search.cpan.org/~smueller/Math-Symbolic-0.502/
Symbolic calculations
----
Sniffer-HTTP-0.14
http://search.cpan.org/~corion/Sniffer-HTTP-0.14/
multi-connection sniffer driver
----
Module-Build-0.28
http://search.cpan.org/~kwilliams/Module-Build-0.28/
Build and install Perl modules
----
Math-MPFR-1.09
http://search.cpan.org/~sisyphus/Math-MPFR-1.09/
perl interface to the MPFR (floating point) library.
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
print "Just another Perl hacker," # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 9210
***************************************