I am trying to make image generator php file and I use this code>
<?php
header('content-type: image/jpeg');
$email = '[email protected]';
$email_length = strlen($email);
$font_size = 4;
$image_height = imagefontheight($font_size);
$image_width = imagefontheight($font_size) * $email_length;
$image = imagecreate($image_width, $image_height);
imagecolorallocate($image, 255, 255, 255);
$font_color = imagecolorallocate($image, 0, 0, 0);
imagestring($image, $font_size, 0, 0, $email, $font_color);
imagejpeg($image);
?>
and it shows no image when I load the file in Chrome. In Mozilla it shows error 'The image "..." cannot be displayed because it contains errors'. But when I put imagejpeg($image,"new.jpg"); instead of imagejpeg($image); it makes the img file correctly. Does anyone know what should I do to fix this problem?
headercall and run the script directly to see if there's any PHP errors coming out. - scrowler