Jump to content

Image not showing up?


3raser

Recommended Posts

Here is my code:

 

<?php
$image = ImageCreateFromPNG("image.png");
$color = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$colorShadow = imagecolorallocate($image, 0x66, 0x66, 0x66);
$font = 'arial';
$fontSize = "11";
$fontRotation = "0";
$message = $_POST['message'];
$str = $message;

/* Shadow */
ImageTTFText($image, $fontSize, $fontRotation, 7, 22, $colorShadow, $font, $str);

/* Top Level */
ImageTTFText($image, $fontSize, $fontRotation, 5, 20, $color, $font, $str);

header("Content-Type: image/PNG");
imagepng ($image);
imagedestroy($image);
?>

 

When you visit http://srl.comoj.com/submit.php (after you've typed in your message), it doesn't display the image.....it just gives me the image icon error or whatever you call it. The image you get when a image isn't working or it's invalid.

Link to comment
https://forums.phpfreaks.com/topic/193415-image-not-showing-up/
Share on other sites

submit.php

 

This is because you have to use the HTML img tag with the src attribute as the file that created (and, in this case; destroyed) the image. I.e

<img src="http://srl.comoj.com/submit.php" >

 

In the file in which you wish the image to be displayed.

You will also need to use get data, then you create a page with

<img src="http://srl.comoj.com/submit.php?message=Get message here!" >

<?php
$image = ImageCreateFromPNG("image.png");
$color = imagecolorallocate($image, 0xFF, 0xFF, 0xFF);
$colorShadow = imagecolorallocate($image, 0x66, 0x66, 0x66);
$font = 'arial';
$fontSize = "11";
$fontRotation = "0";
$str = isset($_GET['message']) ? $_GET['message'] : 'Default here.';

/* Shadow */
ImageTTFText($image, $fontSize, $fontRotation, 7, 22, $colorShadow, $font, $str);

/* Top Level */
ImageTTFText($image, $fontSize, $fontRotation, 5, 20, $color, $font, $str);

header("Content-Type: image/PNG");
imagepng ($image);
imagedestroy($image);
?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.