Jump to content

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);
?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.