Jump to content

JPEG headers


dig412

Recommended Posts

I'm using this code to make a simple speech bubble generator, and so far its working fine. However, if you choose 'save image' in firefox, it will save the blank image without the added text. It saves properly in ie, so i dont know exactly whats wrong.

[code]if (isset($_GET['mode'])){
if ($_GET['mode'] == "img") {
header ("Content-type: image/jpeg");
header('Content-transfer-encoding: binary');
putenv('GDFONTPATH=' . realpath('.'));
$image = $_POST['image'];
if ($image == "shout") {
$img_handle = @ImageCreateFromJPEG ("domotalk.jpg");
}
else{
$img_handle = @ImageCreateFromJPEG ("domonews.jpg");
}
$txt_color = ImageColorAllocate ($img_handle, 0, 0, 0);
$text = $_POST['usertxt'];
if ($image == "shout") {
$newtext = wordwrap($text, 17, "\n", 1);
}
else {
$newtext = wordwrap($text, 20, "\n", 1);
}
$font = 'arial';
if ($image == "shout") {
ImageTTFText ($img_handle, 14, 0, 207, 62, $txt_color, $font,"$newtext");
}
else {
ImageTTFText ($img_handle, 14, 0, 280, 75, $txt_color, $font,"$newtext");
}
ImageJPEG ($img_handle,'',95);
}
} [/code]

I'm assuming that it's got something to do with the headers.
Any ideas?

EDIT:
It seems it doesn;t work with IE anymore. hmm
Link to comment
Share on other sites

  • 2 years later...
[code]<?
if (isset($_GET['mode'])){
if ($_GET['mode'] == "img") {
header ("Content-type: image/jpeg");
header('Content-transfer-encoding: binary');
putenv('GDFONTPATH=' . realpath('.'));
$image = $_POST['image'];
$text = $_POST['usertxt'];
$txt_color = ImageColorAllocate($img_handle, 0, 0, 0);
$font = 'arial';
$img_handle = @ImageCreateFromJPEG((($image == "shout")? "domotalk":"domonews").".jpg");
if ($image == "shout") {
$newtext = wordwrap($text, 17, "\n", 1);
ImageTTFText($img_handle, 14, 0, 207, 62, $txt_color, $font, $newtext);
}
else{
$newtext = wordwrap($text, 20, "\n", 1);
ImageTTFText($img_handle, 14, 0, 280, 75, $txt_color, $font, $newtext);
}
ImageJPEG ($img_handle,NULL,95);
}
}
?>[/code]

only problem I can see is $font is being set to 'arial' and 'arial' is not a font file.. the font parameter for imagettftext is a FONT FILENAME

yes I know this post is over 2 yrs old.. whatever.. I'm bored
Link to comment
Share on other sites

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.