Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Inline images in POD

by LanX (Canon)
on Dec 09, 2008 at 01:56 UTC ( #729067=note: print w/ replies, xml ) Need Help??

in reply to Re: pod and images
in thread pod and images

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

Comment on Inline images in POD
Select or Download Code
Re: Inline images in POD
by dpchrist (Initiate) on Nov 17, 2011 at 04:12 UTC

    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?

        data:-URLs are nice, but they have limits: Old browsers and especially IE<7 can't handle them, IE<9 has some arbitary limits for the data URL length. See for a good overview.

        Base64 encoding can be done from the command line, as documented in MIME::Base64.


        Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      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://729067]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (14)
As of 2014-07-11 18:27 GMT
Find Nodes?
    Voting Booth?

    When choosing user names for websites, I prefer to use:

    Results (234 votes), past polls