Re: [PHP] Problems creating images

2006-04-13 Thread Richard Lynch
On Wed, April 5, 2006 2:42 pm, Age Bosma wrote:
 *confirm_image.php:*

Your browser and webserver see confirm_image.php in the URL.

   Header(Content-type: image/jpeg);

REAL browsers like Mozilla and Firefox etc trust this.

Microsoft, however, in its infinite wisdom, ignores
standards-compliant Content-type: headers and guesses at the content
type from the URL.

Thus, odds are really good that some versions of IE on some versions
of MS will decide that your image must be a JPEG.

The only generalized solution I know of is to make sure you IMG tag
*ends* with .jpg

imt src=confirm_image.php/ie_sucks.jpg /

IE (some versions) will see the .jpg and know it's a JPEG, and
ignore the Content-type:

   ImageString ($image, 5, 12, 2, $code, $text_color);
   ImageJPEG($image, '', 75);
   ImageDestroy($image);

 Most people get a nice image but some people get only, what appears to
 be, garbage:

 ÿØÿàJFIFÿþ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62),
  XXX

The stuff above XXX...

That doesn't look like valid JPEG starting characters in my experience...

PERHAPS they're fine, or part of some new standard, but every JPEG I
ever saw started with the stuff above 

It's possible that your code_bg.jpg has EXIF data and/or is a
progressive JPEG, and that GD preserves that info, and that some
browsers are incapable of displaying such a JPEG.


 For the complete output have a look here:
 http://www.samuel-area.de/phpbook/confirm_image.php

The crucial thing here is that SOMETHING is forcing some kind of
output and the Content-type: is being set to text/html on that server
for that URL:

-bash-2.05b$ telnet www.samuel-area.de 80
Trying 82.149.248.196...
Connected to www.samuel-area.de.
Escape character is '^]'.
GET /phpbook/confirm_image.php HTTP/1.0
Host: www.samuel-area.de

HTTP/1.1 200 OK
Date: Fri, 14 Apr 2006 00:02:11 GMT
Server: Apache/2.0.53 (Fedora)
X-Powered-By: PHP/4.3.11
Content-Length: 1519
Connection: close
Content-Type: text/html; charset=iso-8859-1

JFIF;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), quality = 75
C
 $.' ,#(7),01444'9=82.342C

 Do you know what is going wrong here?

So, most definitely, in this case, something is configured incorrectly
on that server to over-ride your header() call and it's spewing out
the JPEG as if it were HTML.

My first guess would be some kind of security setting/module which is
trying to be smart about .php which is forcing the final output
Content-type: to be text/html, even though PHP is perfectly capable of
generating ANY kind of content.

Since it's an Apache server, if the trick above (end URL in .jpg) does
not work, you could try this:

#1
mv confirm_image.php confirm_image.jpg

Now the URL will look JUST like a .jpg to everybody.

#2
Edit a file .htaccess in that same directory as confirm_image.php and
add this to it:
Files confirm_image.jpg
  ForceType application/x-httpd-php
/Files

Now Apache knows that this particular .jpg file should be passed
through PHP to generate output.

#3
Change your IMG tag to point to:
confirm_image.jpg

If that STILL doesn't fix it, you're going to have to get the
administrator of that server to figure out why their server insists on
spewing out Content-type: text/html for a dynamic JPEG.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: Re[2]: [PHP] Problems creating images

2006-04-13 Thread Richard Lynch
On Thu, April 6, 2006 5:24 pm, Tom Rogers wrote:
 put

 error_reporting( E_ALL);

 at the top of the script and see if any error messages show up.
 The fact that the mime type is text seems to indicate some output has
 gone to
 the client before your header call. That could be any white space
 outside of
 ?php..? and could be in an include file or prepend file as well.

Actually, if it's an auto_prepend file, you'll need to change the
reporting level in .htaccess, or it's too late by the time your script
starts executing, no?

php_value error_reporting 2047

Note: I don't think E_ALL is kosher in .htaccess, so I used the value
of E_ALL my PHP reports from:

php -r  'echo E_ALL, \n;'

I think E_ALL changed value at some point, though...

Maybe you can have your client put up a ?php echo E_ALL;? page.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problems creating images

2006-04-06 Thread Age Bosma

Tom Rogers wrote:




Make sure you don't have any blank lines before the ?php



There isn't. I've got the suspicion it's got to do with the UTF-8 
character encoding because of the characters '', I've seen this 
before with HTML pages. Because of this I asked the person who's having 
the problems to upload and test three different files versions of the 
php file:


- ANSI
- UTF-8
- ANSI UTF-8 without BOM

None had any effect what so ever. What else can I try?

Philip Hallstrom pointed out that the returning header is set to 
'Content-Type: text/html; charset=iso-8859-1' instead of 'Content-type: 
image/jpeg'. What could be the cause of this?


Yours,

Age

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re[2]: [PHP] Problems creating images

2006-04-06 Thread Tom Rogers
Hi,

Friday, April 7, 2006, 6:20:41 AM, you wrote:
AB Tom Rogers wrote:


AB There isn't. I've got the suspicion it's got to do with the UTF-8 
AB character encoding because of the characters '', I've seen this 
AB before with HTML pages. Because of this I asked the person who's having 
AB the problems to upload and test three different files versions of the 
AB php file:

AB - ANSI
AB - UTF-8
AB - ANSI UTF-8 without BOM

AB None had any effect what so ever. What else can I try?

AB Philip Hallstrom pointed out that the returning header is set to 
AB 'Content-Type: text/html; charset=iso-8859-1' instead of 'Content-type: 
AB image/jpeg'. What could be the cause of this?

AB Yours,

AB Age


put

error_reporting( E_ALL);

at the top of the script and see if any error messages show up.
The fact that the mime type is text seems to indicate some output has gone to
the client before your header call. That could be any white space outside of
?php..? and could be in an include file or prepend file as well.
-- 
regards,
Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problems creating images

2006-04-05 Thread Philip Hallstrom
I added image confirmation to a guestbook and even though it works greate for 
most people, some people have problem and I can't seem to figure out why this 
happens. Note that I'm not talking about the same guestbook on one server but 
the guestbook is on people's own hosting server.


The php code to create the image can't be simpler:

*confirm_image.php:*
$datekey = date(F j);
	$rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $cfg_sitekey . 
$random_num . $datekey));

$code = substr($rcode, 2, 6);
$image = ImageCreateFromJPEG(images/code_bg.jpg);
$text_color = ImageColorAllocate($image, 80, 80, 80);
Header(Content-type: image/jpeg);
ImageString ($image, 5, 12, 2, $code, $text_color);
ImageJPEG($image, '', 75);
ImageDestroy($image);

Most people get a nice image but some people get only, what appears to be, 
garbage:


JFIF;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), 
quality = 75 C    $.' 
,#(7),01444'9=82.342C  
2!!22

...snip...

For the complete output have a look here:
http://www.samuel-area.de/phpbook/confirm_image.php

Do you know what is going wrong here?


Not entirely, but when I go to that URL and check the headers (Live HTTP 
header extension in firefox) I get this:


HTTP/1.x 200 OK
Date: Wed, 05 Apr 2006 20:02:02 GMT
Server: Apache/2.0.53 (Fedora)
X-Powered-By: PHP/4.3.11
Content-Length: 1501
Connection: close
Content-Type: text/html; charset=iso-8859-1

Notice that last one... I see you set it up above, but it isn't 
sticking


-philip
-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP] Problems creating images

2006-04-05 Thread Age Bosma

Hi,

I added image confirmation to a guestbook and even though it works 
greate for most people, some people have problem and I can't seem to 
figure out why this happens. Note that I'm not talking about the same 
guestbook on one server but the guestbook is on people's own hosting server.


The php code to create the image can't be simpler:

*confirm_image.php:*
$datekey = date(F j);
	$rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $cfg_sitekey . 
$random_num . $datekey));

$code = substr($rcode, 2, 6);
$image = ImageCreateFromJPEG(images/code_bg.jpg);
$text_color = ImageColorAllocate($image, 80, 80, 80);
Header(Content-type: image/jpeg);
ImageString ($image, 5, 12, 2, $code, $text_color);
ImageJPEG($image, '', 75);
ImageDestroy($image);

Most people get a nice image but some people get only, what appears to 
be, garbage:


ÿØÿàJFIFÿþ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), 
quality = 75 ÿÛC    $.' 
,#(7),01444'9=82.342ÿÛC  
2!!22ÿÀ

...snip...

For the complete output have a look here:
http://www.samuel-area.de/phpbook/confirm_image.php

Do you know what is going wrong here?

Yours,

Age

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Problems creating images

2006-04-05 Thread Tom Rogers
Hi,

Thursday, April 6, 2006, 5:42:05 AM, you wrote:
AB Hi,

AB I added image confirmation to a guestbook and even though it works 
AB greate for most people, some people have problem and I can't seem to 
AB figure out why this happens. Note that I'm not talking about the same 
AB guestbook on one server but the guestbook is on people's own hosting server.

AB The php code to create the image can't be simpler:

AB *confirm_image.php:*
AB $datekey = date(F j);
AB $rcode = hexdec(md5($_SERVER[HTTP_USER_AGENT] . $cfg_sitekey . 
AB $random_num . $datekey));
AB $code = substr($rcode, 2, 6);
AB $image = ImageCreateFromJPEG(images/code_bg.jpg);
AB $text_color = ImageColorAllocate($image, 80, 80, 80);
AB Header(Content-type: image/jpeg);
AB ImageString ($image, 5, 12, 2, $code, $text_color);
AB ImageJPEG($image, '', 75);
AB ImageDestroy($image);

AB Most people get a nice image but some people get only, what appears to 
AB be, garbage:

AB ÿØÿàJFIFÿþ;CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), 
AB quality = 75 ÿÛC    $.' 
AB ,#(7),01444'9=82.342ÿÛC  
AB 2!!22ÿÀ
AB ...snip...

AB For the complete output have a look here:
AB http://www.samuel-area.de/phpbook/confirm_image.php

AB Do you know what is going wrong here?

AB Yours,

AB Age


Make sure you don't have any blank lines before the ?php

-- 
regards,
Tom

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php