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
https://forums.phpfreaks.com/topic/3642-jpeg-headers/
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
https://forums.phpfreaks.com/topic/3642-jpeg-headers/#findComment-726114
Share on other sites

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.