This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Display Png Image In Html Using Perl

Hello everyone,

I want to display png image in html but the output is in binary format somthing like below

‰PNG

���
IHDR��Ð���P���¦²_��=PLTEÿQ�Í…?.‹WkŽ#ðÿððæŒK�‚�ÿÿ2ÿ��ÿÿŒ�ÿ¥�HÑÌÒiêÿ�ÿäµúë×õõõ€€€€���¿ÿ€�
€ÿäáH=‹ÿëÍF‚´ÿÿ�ÿê�™2̸†úðæGÿ�@àÐÿõîÿÚ¹/OOÿÖ�™ÿ�úúÒ�ÿÿÌÿ�Uk/eÿ�ú€rÿ�¼àÿÿ=ÿ�­ØæÝ
Ýôÿ�ýõæÿúÍîèªÿ��€€wˆ™ÿ��ÿÞ­øøÿô¤`"‹"�pÛÿ2�fͪÿ¶Áÿe�ÜÜÜ�‹‹Ç…Ò´Œ€€€°ÄÞÿÀËðÿÿÿcGÿ™�ÿ·�jZÍÿÿà
ÿ��d�ÿðõ‡ÎúÓÓÓÿ(�îiiiÿ�ÿÿ„�Qÿ�{hî��Íÿ z‹EÿG�ºUÓÿÌ�ÿ�€�ÿ���€ÚpÖ 
¥**šÍ2ÿÿ�Þ¸‡�ÿ�õÿúÿ�ÿE�Ûp�Žÿ�ÿ�|ü�õÞ³ÿÿð€€�[ÿ�©©©˜û˜zÿ�‹�‹�úšp€Öÿ����é–z�ÿ�ÿ�àÿ�Ú¥
pææú¼��‹�ÎÑAiáÿà�°àæ(ÿ�Š+âÿô�_ž ­ÿ�Ø¿Ø ²ªÿïÕÜ<ÀÀÀ­ÿ/ÿz�‡Îë¯îî£ÿ�ÿ­�‹��ÿÿÿ R-d•íÿ=�ÿ
£�ÿ[�½·kÿ�î‚îÿPpÿ�ð€€õõÜ„ÿ�Í\\ÿúðÁÿ�ÿøÜÿäÄÿi´ÿ×���ÿ·ÿ�”�ÓÿÁ�²""2Í2ÿŽ�ÿúúÿ�ÿÿp�ðøÿ<
³qÿÔ+LŽŒ��ãIDATxœíÝrã …ae®‘óÌ=ú&Ü53B

Code:

use Bio::Graphics;
use Bio::SeqFeature::Generic;

binmode STDOUT;
print  $panel->png;

Thanks

bioperl perl

Closing this as off topic.. the available answers should suffice anyway.

Voting to close this as off topic.. the available answers should suffice anyway.

2 answers

I think you are trying to print the output from your BioPerl script to the STDIO. Instead of printing your output on the terminal / html page, try to print image to a file name defined using STDOUT or forward output file to a .png file.

use something like

perl create_image.pl > foo.png

Now use the file name of image (foo.png) with in your html page. For example:

<img src="foo.png" alt="foo here" />

Rajesh, you can actually create the HTML and PNG in one go, as one HTML file, by embedding the PNG image in the HTML itself, which I think you may be interested in. The details can be found in the, for example, this StackOverflow question, and it basically comes down to a carefully crafted [?] element. Something like this answer:

<img alt="My Image" src="data:image/png;base64,iVBORwA<MoreBase64SringHere>" />

I understood it does not necessarily work in all browsers.

Log in to answer this question.