Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Store image in string

by kejohm (Hermit)
on Mar 14, 2011 at 02:21 UTC ( #893018=note: print w/ replies, xml ) Need Help??


in reply to Store image in string

You could store the image data encoded as something like Base64, and then decode it when you print it to file, like this:

#!perl use strict; use warnings; use MIME::Base64; my $data = < base64-encoded data here >; open my $outfile, '>', 'file.gif' or die $!; binmode $outfile; print {$outfile} decode_base64($data); close $outfile;

See the MIME::Base64 manpage for information about Base64 encoding, as well as examples of encoding files.

Update: Oops, sorry Grandfather, you were too quick for me.

Another Update: Link fixed.


Comment on Re: Store image in string
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://893018]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2014-10-23 21:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (129 votes), past polls