For Programmers: Free Programming Magazines  


Home > Archive > PHP Programming > June 2007 > Re: get image size from binary data









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: get image size from binary data
Christoph Burschka

2007-06-27, 8:00 am

Armand Brahaj wrote:
> james.gauth@googlemail.com wrote:
>
> Someone correct me if I am wrong, but whenever you open an image/file to
> read (even if you want to read the headers) you are storing it to some
> temporary buffer/space on your machine!
> Maybe the GD solution above is the best!
>
> Armand


Yeah, so I'd be downloading the image data, saving it to a temporary
file, reading the temp file into the buffer and getting the header. Not
exactly efficient.

Thanks for imagecreatefromstring(); that was exactly the function I was
looking for!

--
cb

peter

2007-06-27, 7:01 pm


> Yeah, so I'd be downloading the image data, saving it to a temporary
> file, reading the temp file into the buffer and getting the header. Not
> exactly efficient.
>
> Thanks for imagecreatefromstring(); that was exactly the function I was
> looking for!


How else do you expect a system to know details of files on other systems
without downloading them?

I have a book beside me how many pages has it got, what is the author and
what is the title? This is basically what you are wanting your script to do.


Christoph Burschka

2007-06-28, 7:00 pm

peter schrieb:
>
>
> How else do you expect a system to know details of files on other systems
> without downloading them?
>
> I have a book beside me how many pages has it got, what is the author and
> what is the title? This is basically what you are wanting your script to do.
>
>


To complete the analogy, you open the book and count the pages. You do
not xerox the book page by page, then open the copy. ;)

It doesn't matter if fsockopen(url) -> imagecreatefromstring() ->
imagesx() uses temporary files (a process I can't influence anyway),
fsockopen() -> fwrite() -> getimagesize() is likely to use one more.

Even if they are equally efficient, the first method handles it in the
background without making me juggle files in my own code, removing a
frequent source of bugs.

--
cb
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com