Re[2]: [PHP] Finding the height of a JPG in pixels using PHP
| From: | Tom Rogers | Date: | Sun, 06 Apr 2003 05:39:32 +0000 |
| Subject: | Re[2]: [PHP] Finding the height of a JPG in pixels using PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-142572@lists.php.net to get a copy of this message | ||
Hi,
Sunday, April 6, 2003, 2:51:36 PM, you wrote:
Dd> <snip from "Andrew Brampton" andrew@bramp.freeserve.co.uk>
Dd> You can use getimagesize on a jpg file to read its size, so either
Dd> save the jpg in MySQL to a file and then do a getImageSize, or before you place the jpg in to
Dd> the database read its size and store its dimensions with it in the db.
Dd> </>
Dd> I disagree with Andrew. In my humble opinion, I don't think you need to duplicate
Dd> information. Before you decide, have a better viewing of the problem.
Dd> Not a good solution for me.
Dd> I know little about JPEG files, but I know they have a HEADER. This header may contain the
Dd> value (binary, o' course) you need, and even more info than you think. :) So, search a for JPG
Dd> file's
Dd> spec before you continue. Very easy to find.
Dd> After you know about the files you work with, you have to know how to tell PHP to do what you
Dd> want to do. I am not a good person to tell you that, as I am such a newbie to PHP. I can only tell
Dd> that this would be "pisso chocka cake" in assembly. (VERY VERY easy =)
Dd> <snip from "Phil Schwarzmann" phil.schwarzmann@filanya.com>
Dd> I have JPG files stored as binary in a MySQL database. I am
Dd> displaying the JPGs on the screen and also want to know the height (in pixels) of the JPG.
Dd> </>
Dd> Another solution would be if PHP *already* has integrated processing of JPG files, wich maybe
Dd> true, judging by the intricate relation of PHP and internet, and JPG being this commom. I think a
Dd> file extension wouldn't stand in the way (wich I think is what you, Phil, meant by
Dd> "stored as binary" - no extension) Just check that.
Dd> Also, Phil, snipets of the code you use, help you and us much better.
Dd> Regards,
Dd> --
Dd> __________________________________________________________
Dd> Sign-up for your own FREE Personalized E-mail at Mail.com
Dd> http://www.mail.com/?sr=signup
You will find it much easier to store the size info at the time of upload than dicking around with
binary files. In fact I would store the whole serialized array that is returned by getimagesize()
so all info would be available later.
--
regards,
Tom