2 scripts( really one )
First one is used to create the img you wish to be included into your script.
#!/usr/bin/perl use warnings; use strict; use MIME::Base64; my $image; open(IMAGE, 'img.jpg') or die $!; while(<IMAGE>){ $image .= $_; } close(IMAGE); my $encoded = encode_base64($image); print $encoded;
2nd is the code that reads the image and prints it from the script.
#!/usr/bin/perl use warnings; use strict; use MIME::Base64; my $image; while (<DATA>){ $image .= $_; } print "Content-type: image/jpeg\n\n"; print decode_base64($img); __END__ /9j/4AAQSkZJRgABAgEASABIAAD/7QtyUGhvdG9zaG9wIDMuMAA4QklNA+kA SAAAAAADGAJB//f/9wNAAkogAgV7A+AAAAAAAWgBaAAAAAAPeAtFAWwAMgtF Jw8AAQABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQBkAAAAAAAAAAACABCxBQAR QklNA+0AAAAAABAASAAAAAEAAQBIAAAAAQABOEJJTQPzAAAAAAAIAAAAAAAA AAEAADhCSU0nEAAAAAAACgABAAAAAAAAAAI4QklNA/UAAAAAAEgAL2ZmAAEA L2ZmAAEAoZmaAAYAAAAAAAEAMgAAAAEAWgAAAAYAAAAAAAEANQAAAAEALQAA A/gAAAAAAHAAAP////////////////////////////8D6AAAAAD///////// ////A+gAAAAA/////////////////////////////wPoAAAAAP////////// //8D6AAAOEJJTQQIAAAAAAAQAAAAAQAAAkAAAAJAAAAAADhCSU0ECQAAAAAJ OQAAAYAAAFWAAAAJYQAYAAH/2P/gABBKRklGAAECAQBIAEgAAP/+ACdGaWxl QWRvYmUgUGhvdG9zaG9wqCA0LjAA/+4ADkFkb2JlAGSAAAAAAf/bAIQADAgI FQ8MDA8VGBMTFRMTGBEMDAwMDAwRDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwM Dg4QFA4ODhQUDg4ODhQRDAwMDAwREQwMDAwMDBEMDAwMDAwMDAwMDAwMDAwM /8AAEQgAOQCAAwEiAAIRAQMRAf/dAAQACP/EAT8AAAEFAQEBAQEBAAAAAAAA CwEAAQUBAQEBAQEAAAAAAAAAAQACAwQFBgcICQoLEAABBAEDAgQCBQcGCAUD

The gibberish is the encoded output you got from the first script. ( its not a pic so dont expect it to output anything of use to you ). This was posted on a newsgroup a few months back, can't remember who posted it but i've used it from time to time.

Documentation:
MIME::Base64

Have any problems let me know.

-bn

In reply to Re: Binary Challenge by BeernuT
in thread Binary Challenge by Buzz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.