kepler has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Outputing image in perl script/cgi
by LanX (Saint) on Nov 08, 2015 at 12:04 UTC
    > My problem is that I also output html/text content.

    ???

    I suppose you are aware of the img tag and your problem is that the image data is generated dynamically.

    The classic answer is either to statically store the image or to link in the image src url to a second cgi call requesting the image.

    An alternative with "new" browsers is base64 encoding of an inlined image.

    <img src="data:image/gif;base64, iVBORw0KGgoAAAANSUhEUgAAABUAAAAWCAQAAACFih+zAAACxmlDQ1BpY2MAAHjajZPLax +RZFIe/ 6tygkCAMtK9eDJdZSJAklA80Ij7SSWyisW3KRJMgSKf6dneZm+qaW9VxFBHJxqXOMHvxsX +DhH+DC hSvdKBF8IYh7FUUU3Ki0i+p0V/B5Vl/9zrm/c84tLnTaxSDQKQlzfmScXFZOTk3LFc9IsZ +4uMnQV 3TAYLBTGAIpBoPkmPj7BAnjY9/38T6OrFLpzYK2E1PuSCl3o+AzUKpNT0yA0kD4ZBRGIc0 +DaxPr/ QHom5utA2ow7QyBuAavcwEQg7gEDbrVYgk4B9FYSNTMJntN1tznPH0C38icOAxsgdVaFI0 +22FkrF 4QNAP1ivSmp4BOgF63rZ2zcK9ADPy2bfRMzWRi8aHY85dcTX+bEmr/Nn8oeaniKIss6Sfz +h/eGRJ P1HcXwAyYDmztQMOsAZSe09Xx4/GbOnT1aF8kx+ZujMB/AWpa4EujMWzpe4whUbh4aPwkT +jkyNJH gKFGGQ8PjUcOhY/C4BEy+91KTSHBkhwv8XmJweNv6igkDkfI5lnobTlI+6n9xn5sX7av2a +8vZuo9 7cyCOe65ixfeUUBhWr7NbHOm2N+lxiAaTQXFXGunMDFpYrqyfzHTdnIXL7xT5/MfE1uqRK +c+ZlCE zGLwmEehCVEMJrr96PYU+u6ZW+vavR6Lm8cedt89s+yuat9spVpbLf9u1yXPK/Gn2CRGxY +DYgRR7 xF6xWwyLAbFTjLVOTODjcRKFIaSIxucUct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O1/mKS6GaQtAz/ZuEjoFutmRHVkd/4frOHmQxRTGf +YAAAAl dEVYdGRhdGU6Y3JlYXRlADIwMTUtMDItMDJUMjA6MTM6MzcrMDE6MDD6p3X7AAAAJXRFWH +RkYXRl Om1vZGlmeQAyMDE1LTAyLTAyVDIwOjEzOjM3KzAxOjAwi/rNRwAAAABJRU5ErkJggg==">

    (Not really a perl question)

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!

      Hi. I understand. But my image generates this: ÿØÿá :/ ...
        What is the question?

        What did you try?

        What did you get?

        What do you want to get?

        Please try to phrase posts which can be answered without semi telepathic guessing.

        It might probably and under some circumstances be (i.e. let's suppose) that you want to google for "base64 and perl" but I'm not going to do it for you if you don't even show any efforts in expressing your problem.

        Our maybe not? Who knows?

        Cheers Rolf
        (addicted to the Perl Programming Language and ☆☆☆☆ :)
        Je suis Charlie!

        A reply falls below the community's threshold of quality. You may see it by logging in.
        If your image is generating high-bit characters, then you aren't encoding it in base64. MIME::Base64

        #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re: Outputing image in perl script/cgi
by nikosv (Deacon) on Nov 08, 2015 at 19:49 UTC
    have you set STDOUT to binmode? binmode STDOUT
    have you use the right header ? header("image/png")
Re: Outputing image in perl script/cgi
by Anonymous Monk on Nov 08, 2015 at 21:37 UTC