Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: pod and images

by LanX (Bishop)
on Dec 08, 2008 at 19:05 UTC ( #729010=note: print w/replies, xml ) Need Help??

in reply to pod and images

There is an inline image format supported by many mail readers and even browsers! It is base64 encoded. You've certainly seen this in in plain mail texts.

But what you'll need is to realize a POD-Parser transforming it in HTML or PDF.


  2. Sending Inline Images in e-mail with Mail::Sender (or getting them to print in Outlook)

Cheers Rolf

Replies are listed 'Best First'.
Inline images in POD
by LanX (Bishop) on Dec 09, 2008 at 01:56 UTC
    I was interested and fiddled abou it. And this seems to work without any extra podparser.

    Download this code to

    for (1.10) { print; } =for html <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAY +AAAAeP4ixAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAA +CxMBAJqcGAAAAAd0SU1FB9gEEgIJDgjXTxYAAAE3SURBVGje7VhBDsMwCAPU/3+ZXbdKC +RDMlLRwjJBqg4lpWFWVioOZqz9BQg+JxxC5bhKAaWAkWVVloGS1pXWEtKJSYfB19C2VqB +QlqXetJDE7DxOxwCLIWGA9ZAQBMkPGW3Er7/m3VrTKK13xdsOT3z5yDJGoR6x4SnRdmeW +/Q1reKmcc3tsVK0+yIBFrigXSQ1YyFQev/Zzp2FU5zNXD3z6yc3C/orS0mshcvkRUPiN/ +GMOW1nbx4+xKwFdAGvzNMeHuYqV+aTxDWlGpIKV4l0pUipLR+3AOUCRm5+EfKwMshIwF1 +kFGECBTZJwVt/Je8BwUrPJSVzS4Hk3y20eOIRL1iCVPia4rk/x3SMtb5ZTDe7ti5EkWJG +RNscg4yEqm4tBdawTW2bGrdJirh799ZOPoV5Td4gPKYZdm2PperwAAAABJRU5ErkJggg= +=" title="img-tag, normal" alt="Inlineimage"> print "dummycode";
    and call
    pod2html >pod_img.html
    the resulting html-file shows an image in most modern browsers! (Officially also in IE7, but I couldn't test it! So please tell me if ...)

    PLEASE NOTE: The image data is in one long line, the linebreaks were inserted by the perlmonks-formatter.

    Cheers Rolf

      How did you create the src string?



        See URI::data - URI that contains immediate data

        #!/usr/bin/perl -- use strict; use warnings; use URI; use IO::File; my $u = URI->new("data:"); $u->data(join '', IO::File->new( 'camel.favicon.png' , '<:raw' )->getl +ines ); $u->media_type("image/png"); print qq[<p><img src="$u">\n]; __END__ <p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAVCAI +AAADJt1n/AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICE +AAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAKdJREFUOE/Fk2sOgCAMg/HqxpuZe +C1sqI5ReSh/JATB7Os6HkuMMUw3wNMttMhjP7Z16+vWYWDWO3yGUTgAG5mZvcVfMIMAIA +4jd9D4AWwAJYj5Q6jyWrO3yjkL8TD+cKmwVC6w2SlgaH3qCpfGmlrpRl6xt/v0ZXKbVL2 +8hc1LTnVLV2z7zGLkucy7bdo+SDKLtMK+SKl8nFngD5nnz7n/bgcP4wf4BN5NffCErP3u +AAAAAElFTkSuQmCC">

        FWIW, new questions go in Seekers Of Perl Wisdom

        Welcome, see The Perl Monks Guide to the Monastery, see How do I post a question effectively?, Where should I post X?

        3 years ago?

        I think I simply mailed it to myself and copied the base64 encoding.

        Cheers Rolf

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://729010]
[moritz]: specially if you're used to markdown
[holli]: there probably is some nodelet hack that lets you use markdown :)
[LanX]: a) well ... you can use the xml-version to get the original code w/o need of reverse engineering
[moritz]: yes, and that's the next problem: there are piles of workarounds, but not solution, no visible progress
[LanX]: b) you cahnge my wikisyntax to support markdown and stay PM compatible
[holli]: see moritz, the , how do i put it, robust charme of this site is what separates the wheat from the chaff ^^
[LanX]: I'm willing to improve the code, but we have a götterdämmerung at the moment, Corion is the only active god for some time now
[moritz]: and everybody is like "if you just copy 250 lines of ugly JS into your free nodelet, and happent to know about it, there is a 40% that this workaround kinda works, sometimes"
[moritz]: ... "so there is no need to do anything"
[LanX]: and the code is a bit of a mess

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (12)
As of 2017-11-20 19:21 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (291 votes). Check out past polls.