|
Posted by Richard Lynch on 01/06/05 18:43
Liam Gibbs wrote:
> print("<IMG ALT... HEIGHT... WIDTH... SRC = \"" . copy_pic($sourcepic) .
> "\">");
>
> So I'm calling the function straight from the SRC attribute of the IMG
> tag. Here's what's in my function:
>
> function copy_pic($sourcepic) {
> if(file_exists($sourcepic)) {
> $destinationpic = imagecreatetruecolor(imagesx($sourcepic),
> imagesy($sourcepic));
> imagecopy($destinationpic, $sourcepic, 0, 0, 0, 0,
> imagesx($sourcepic), imagesy($sourcepic));
> }
>
> return $destinationpic;
> }
>
> After this, I'm going to be tampering with the pic, but I just wanted to
> make sure I'm getting something, which I'm not. All I get is a broken
> image. No error message, no nothing. Please tell me I'm not overlooking
> some really idiotic thing, but I'm just having one heckuva time with this.
Not idiotic at all.
You have to sort of "un-learn" something, and wrap your brain around a new
concept. :-)
You know how PHP spits out HTML?
Yeah, well, PHP doesn't *just* spit out HTML.
PHP can *also* spit out an actual JPEG.
Like, it spits out what you would get if you opened up a JPEG in a text
editor and you see all that gobbledy-gook.
But to do this, you've *still* got to have it being spit out as *JUST* the
image, in a separate file, the *same* as having a separate JPEG image file
on the server which is not all that gobbledy-gook pasted into your HTML.
Or, to put it this way:
You currently have something like this all in one big file:
<HTML><BODY>
....
<IMG SRC=JPEG%(**&^#@@#R%GFGE#WWRYUIIUUYY**&%*&%$^&%$#%^#%$#%$^%$##@$@#%$^%>
....
</BODY></HTML>
But, a valid setup would have *TWO* files. One with:
<HTML><BODY>
<IMG SRC=otherfile.jpg></HTML>
</BODY></HTML>
otherfile.jpg would have the JPEG stuff in it:
JPEG%(**&^#@@#R%GFGE#WWRYUIIUUYY**&%*&%$^&%$#%^#%$#%$^%$##@$@#%$^%
So you need to move your copy_pic stuff and all of that to a DIFFERENT
file, say "dynamic_jpeg.php".
Your HTML will then have:
<IMG SRC="dynamic_jpeg.php">
in it.
Plus your dynamic_jpeg.php file will have to have this stuff at the end:
header("Content-type: image/jpeg");
imagejpeg($destinationpic);
PS: You may not be *SEEING* the error messages, because they are buried
in the contents of what is supposed to be a JPEG. But if your JPEG looks
like this:
JPEG*(&*^*&^%^&% PHP Error: blah blah blah *&*&^%$$##@@#$%^^^
then it's just a broken JPEG, as far as the browser is concerned.
So surf *DIRECTLY* to it when the browser shows you a broken image icon:
http://sympatico.ca/dynamic_jpeg.php
for example.
--
Like Music?
http://l-i-e.com/artists.htm
[Back to original message]
|