Re: [PHP] Image copying

2005-01-07 Thread Liam Gibbs
Richard, thanks. This made it much clearer. I read this, then stepped away
and thought about it later and it makes so much more sense. Basically, I
guess I ended up with the result  in my HTML.
Man, I thought I was telling it to print the results of the resource ID, but
it was printing it on its own. Now the problem is solved! Thanks so much.

And Jason's little bit helped as well. That was my jumping off point.

Thanks so much, guys! Now onto the next brow-beating

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



Re: [PHP] Image copying

2005-01-06 Thread Richard Lynch
Liam Gibbs wrote:
> print(" "\">");
>
> 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:


...

...


But, a valid setup would have *TWO* files.  One with:




otherfile.jpg would have the JPEG stuff in it:
JPEG%(**&^#@@#R%GFGE#WWRYUIIUUYY**&%*&%$^&[EMAIL PROTECTED]@#%$^%

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:

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

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



Re: [PHP] Image copying

2005-01-06 Thread Jason Wong
On Thursday 06 January 2005 14:24, Liam Gibbs wrote:

> What I'm trying to do is copy one JPEG to another JPEG (as mentioned) on
> the fly. I don't want to have a new file produced, just a modified JPEG (a
> few circles here and there) held in a resource. Here's how I call my
> function and how I display the image via HTML:
>
> print(" "\">");
>
> So I'm calling the function straight from the SRC attribute of the IMG tag.

SRC is supposed to be a URL ...

> 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;
> }

... but you're giving it an image resource!

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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



[PHP] Image copying

2005-01-05 Thread Liam Gibbs
Hello,

I'm having a real frustrating time with my problem here, which is to copy one 
JPEG to another resource. I'm not even sure where I'm going wrong, or how to 
find it out, because it seems that I'm getting all my resource IDs fine (when I 
echo them, I get 'resource ID #x'), and no error message pops up. Just a broken 
image is produced. I've been racking myself for so long now that my problem may 
be right under my nose, but my brain is so baked it's just not working. And 
I've tried to leave and come back to it, but... you know how it is. Here's what 
I'm doing.

What I'm trying to do is copy one JPEG to another JPEG (as mentioned) on the 
fly. I don't want to have a new file produced, just a modified JPEG (a few 
circles here and there) held in a resource. Here's how I call my function and 
how I display the image via HTML:

print("");

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.

Thanks, everyone.