troubleshooting Question

having trouble displaying ph generated image

Avatar of paries
paries asked on
20 Comments1 Solution363 ViewsLast Modified:
if i call this page directly
i get an image displayed in the browser

now i am trying to display this image with a jquery/ajax call.

if i call printTicket and the URL is generateTicket.php
the display is a bunch of unprintable characters

so then i tried
url: "/inc/utils/eticket.php", which is basically ::
    print "<img src = 'generateTicket.php'>";
this displayed nothing

then i tried
    require_once 'generateTicket.php';
and got the garbage again (see image )

thanks for any help


// PHP File used to quickly put some text over a poster image - for video or other.

// To use:  Use this file as the source file of an image.  Pass it two GET variables:  pat=path of image&text=text to overlay

header("Content-Type: image/jpeg");

// Open the image:

$image = imagecreatefromjpeg('/home/events/html/templates/ticket.jpg');

$width = imagesx($image); // Gets the width - better to use imagesx here as we don't need to feed it a path, just a handle.

$rectCol = imagecolorallocatealpha($image, 0, 0, 0, 100); // Create a black colour, slightly transparent
$textCol = imagecolorallocate($image, 255, 255, 255); // Create a white colour

// Fill the top of the image with this rectangle...

//imagefilledrectangle($image, 350, 10, 730, 150, $rectCol);

//imagefilledrectangle($image, 0, 0, $width, 50, $rectCol);

$textX = 350;
$textY = 50; // X and Y values for the text generation

$font = '/home/events/html/templates/verdanab.ttf'; // Replace this with the path to your font file.

// Write Text:
imagettftext($image, 18, 0, $textX, $textY, $textCol, $font, 'test');

// Now we're done editing... output the final image:


// Free up some space:


function printTicket(e, f){
          url: "/inc/utils/eticket.php",
          type: 'GET',
          beforeSend: function(){
            $('#popup').animate({width: "750px"}, 330);
          error: function(jqXHR, textStatus, errorThrown){
              '<div class="error">'
                +'<div class="errorLine">'+textStatus+': '+errorThrown+'</div>'
          success: function(data){
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 20 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 20 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros