note 38651 deleted from function.imagecreatefromstring by nlopess
| From: | nlopess@php.net | Date: | Thu, 01 Jan 2004 16:19:42 +0000 |
| Subject: | note 38651 deleted from function.imagecreatefromstring by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62742@lists.php.net to get a copy of this message | ||
Note Submitter: gzink@zinkconsulting.com
----
Regarding using BLOBs in SQL databases (like but not limited to MySQL) for image storage, a few
thoughts based on the projects I've done:
-BLOBs are a very, very minor performance hit for most low to moderate use sites on shared hosting.
You'll never see a difference in performance in these situations. This is 2004, not 1984,
computers are pretty darn powerful these days and stuff like this is relatively trivial.
-Occasionally, MySQL can boost performance through intelligent caching, making it several times
faster than the filesystem. Your millage will vary depending on file use, database structure, cache
settings, etc but I have seen this as a very real phenomenon in a few cases with medium sized images
(a few megabytes).
-BLOBs have some neat advantages over files making them easier to work with, so for low to medium
traffic sites, BLOBs are a great choice due to these advantages.
-One advantage is security, especially for shared systems. PHP can have read/write on your SQL
database but not on any other files, so other users on the system can't get into your CHMODed
files. (Especially important if you need read/write for your image files)
-Another advantage is portability. I can keep my lean, mean PHP machine and have a second machine
for my MySQL with lots of storage space for my library of images. I can use PHP to retrieve the data
as needed and even move the files around from machine to machine pretty easily. It might even be
reasonable to do distributed (over multiple MySQL servers) image storage with a system like this, if
you have gigabytes and gigabytes of images like I do.
-For very busy sites, storing your images in a SQL database may be a bad idea. Anything that's
static, stick in the images folder. But before you decide against using a database, TRY IT. You may
be surprised at how little impact it has compared to all your other code.
-Once you have the image file in PHP, you may be tempted to do a few fun things with it. Perhaps
bandwidth limiting, session filtering (keep pesky spiders ignoring robots.txt or foreign sites from
downloading your images - check to see that they have a session open from loading one of your
pages), watermarking, whatever else you can imagine...
Hope it helps a few people out there!
-Galen
http://zinkconsulting.com/