Re: Problems creating images

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux