Page 1 of 1

imagecreatefromjpeg - Bandwidth Consuming?

Posted: Sat Sep 29, 2007 7:43 am
by m76
Hi everybody. I'm a new member here, but I used this forum a lot of times to find solutions to php problems, I have a lot of thanks to give to some of you people. :P

Anyway, I've been looking all over google and a few search pages on this forum about this question, but I didn't find my answer. I'll be happy if someone could help me out with this:

I just made a random-pictures system where users can make dynamic pictures, and add a lot of regular pictures to them, so that every time the dynamic pictures are refreshed, they show a different picture.

For the dynamic part I use imagecreatefromjpeg, imagecreatefromgif and imagecreatefrompng, and get the random address from the database. Anyways, it all works great and everything but what I need to know is how does this function (imagecreatefromX) works? Is it just displaying the picture from the remote address, or is it processing it on my server and consumes my bandwidth?

Thanks in advance! :)

Posted: Sat Sep 29, 2007 8:06 am
by jeffery
I would say its consuming the bandwidth of the server where imagecreatefromX is executed on. Because the image is being displayed on the end-users browser after being processed on the server.

what do you mean by "and get the random address from the database"? Are you grabbing a remote image from another server, processing it on the server with dynamic content and then displaying the image ?

Re: imagecreatefromjpeg - Bandwidth Consuming?

Posted: Sat Sep 29, 2007 8:10 am
by volka
m76 wrote:Is it just displaying the picture from the remote address, or is it processing it on my server and consumes my bandwidth?
Like all php it's done server side.

Code: Select all

$i = imagecreatefromjpeg('http://www.serv.er/imagexyz.jpg');
...
imagepng($i);
This This loads the image data via http from http://www.serv.er to your server (net traffic) and then sends the image data as http response from your server to the client (net traffic).

Posted: Sat Sep 29, 2007 8:59 am
by m76
Thanks guys. So if I understand correctly, I guess I should expect some high bandwidth...

Posted: Sat Sep 29, 2007 9:03 am
by feyd
If you serve it more than once, consider saving the file to your local server.