I have searched many sites and most do not seem to work partly because there is some much "extra" stuff with it.
page one has :
- Code: Select all
<html>
<head>
<title>Images</title>
<style></style>
</head>
<body>
<img src="createimg.php" />
</body>
</html>
and the createimg.php :
- Code: Select all
<?php
$im = imagecreatefrompng("pix/bg1.png");
//Output PNG Image
header("Content-Type: image/png");
imagepng($im);
//Destroy the image to free memory
imagedestroy($im);
//End Output
exit;
?>
If I try to open createimg.php it says :
The image “http://127.0.0.1/php/createimg.php” cannot be displayed, because it contains errors.
If I comment out the header line, there is a lot of characters I would assume to be the PNG image.
( A small sample - you can see the PNG part of the file header .... )
- Code: Select all
‰PNG ��� IHDR���È���#���^¹Òˆ��‹IDATxœÍœÙsÇÇ{îÁ} H𾩃¤(QÖe]¶bÇÎÆvœÊz“ì>lmÕîCö!•ªì?ÚÚTå!Þlí‘8öÆGl˺%KÅS¤(^à}€ˆû`î}€DA$ T»ßÔüfÝ===3Ÿþõ¯E���¸rå A.\Hš·nÝ‚ èôéÓIóÞ½{YË[��6“¢··‚ öööäчBtðàÁ¤ùøñc‚“¦Ãဠ¨ºº�ðËß½÷Š\Ť �E±©©)iŠ¢ØÚÚš4»»»EQìììLšwîÜáÌ™3Ióò7WÇãV{ãûÊWݱk7në°ÝN¡««‚ ¬úúú jkkKšÃÃõ´´$Íññq‚êêê’æÌÌAIsvv�Ád9H Ë%°›öH<==Úccc‚ lµÆÃ‡EQ<|øpÒìééEñèÑ£IóîÝ»‚ œ:u*i^¿~]ÅóçÏ?iœË—!zíµ×Ò¶Fww7A[Ym»‚ÛNzzšçùÚÚÚ¤900Àóü‘#G’æÍ›7yžß*÷믿� Gu¸Fçüh‚Ó(°\ÿ�0ê$Þ £SåóßT1¬ðxÖ÷YwØ
Likewise with the header in place, the calling page has a broken image box.
With the header commented out, the page is blank.
if I add an alt tag to the <img src ....... alt="here"> I see the alt text in either instance, with or without the header included.
For some reason it does not like the header command. At least in this instance. I did find one example that creates a grid in code and places text on the grid image and it does show on the calling page.
Am I missing a library? Is my syntax completely off?
Is there a very basic example that could show just an image without anything else "unneeded" included?
Do I need a session established for use?
I am somewhat new to parts of PHP.
I am using the code on a Suse machine with an Apache server running and all code is in the htdocs folders with user:group permissions set viewed in a Firefox browser from localhost.
thanks in advanced for any help.
kumado
I also opened gd_info and have the following:
array(12) { ["GD Version"]=> string(27) "bundled (2.0.34 compatible)" ["FreeType Support"]=> bool(true) ["FreeType Linkage"]=> string(13) "with freetype" ["T1Lib Support"]=> bool(true) ["GIF Read Support"]=> bool(true) ["GIF Create Support"]=> bool(true) ["JPEG Support"]=> bool(true) ["PNG Support"]=> bool(true) ["WBMP Support"]=> bool(true) ["XPM Support"]=> bool(true) ["XBM Support"]=> bool(true) ["JIS-mapped Japanese Font Support"]=> bool(false) }
I made a function from the call and included the file/page in my calling page ( functions.php )
- Code: Select all
function MakeImg ()
{
$im = imagecreatefrompng("pix/bg1.png");
//Output PNG Image
imagepng($im);
//Destroy the image to free memory
imagedestroy($im);
}
and tried to display as : <img src="<?php MakeImg() ?>" alt="there"/>
and the following is displayed on my page :
- Code: Select all
<°é§� ÌÈ\d£j(¡²ìU¹ŠaÅÁ©¨/ÌjQIˆü/ÜNÝAä‹Ì�� œàýøñãI3Þ]>ê÷_ôˆ�zãì!»Y‰ÀPxO0ü?ÿæîÎ×Ôdï¾0›@Þ`â|‡eyæa*¼_½zU„->M=…¯»–‡´VË.œ{’8¼3,§ë‘' ´¬,³*QÎÞaIa×ðFq‘ef1V]?sÔšz4KÒOÂûÇ]±·N–6Vh3ÀûçwægVÈNž8–<šÞûœúïŸ)«-ÓdïG:¾q†p2¸g¡ ï/ £uÒÍêŠbIߨæG׿<D†Ä$Žà(¡¸lrÞôÇûÑáYªÚ¦þ›·kìfeöµ:wÄ"#áÁi*Ë„t4Ã/EƦý¼�ªmXe©E²m™TI…·ûuo‰Î¾n;õï7,¬…¯¾>‹§©ÏoHtÌXV¨±kŠt0š5 'XxrE2¹Î·«ÿò¢qdÆŠeu«ì&¥?wÄ,—`Æ‚›FLy—†cü·×ëÊ4çÚÍÙd%%ÑKÇ
which almost seems to be the image data minus the file header ( both sections are but a small sample of the whole )
again, for any help I would be grateful.

