Page 1 of 1

A PHP Photo Gallery

Posted: Tue Apr 15, 2008 4:53 pm
by onion2k
I decided earlier this evening that my knowledge of PHP 5 completely sucks as I spend most of my days maintaining apps on a PHP 4 server, and I resolved to do something about it - write a photo gallery app in PHP 5 in order to learn all the fancy bells and whistles. So, in my usual launch-into-it-with-the-most-over-ambitious-spec-imaginable style.. let's have a brainstorm!

I want this thing to do lots of fancy but useful things. Think "FlickR as an installable app on a server you control".

My list of features so far

Multiple galleries
Thickbox for viewing images
Secure password protected gallerys
Anti-hotlinking
Automated thumbnail generation with effects
Automatic watermarking
User accounts
View new images
Browse images
Browse by date
Browse by size
Browse by colour
Top rated images (daily/weekly/monthly/alltime)
Metadata for images
EXIF reader for metadata
Tagging
Comments
Ratings
CSS Themes
RSS/Atom feeds
JQuery/Ajax for clientside stuff
Embeddable into other websites
User management for integration into other websites (eg sharing users with forum software)
Slideshow???
URL Rewriting???
Imagemagick support???
Google Maps intergration???
Blogging/Photo blogging???
Video upload???
Text upload (for prose galleries)???
Automated code update???

Ones with ??? are things I'm not sure about adding. They're not essentials.

What have you seen on galleries and thought "Woah.. cool!" or thought "I wish this had..."?

Re: A PHP Photo Gallery

Posted: Tue Apr 15, 2008 6:24 pm
by seodevhead
Camera Raw Conversion.

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 12:45 am
by matthijs
That sounds interesting. Are there any other goals for you, besides doing more with php5?

With existing gallery systems, it's the same as with e-commerce/shopping carts: there are many out there, each with their own nice things but almost always with something missing. Most often a solid layer of code ;) If even I, with my limited programming abilities, can see that something is wrong by looking at the code, you know it's just a hacked together bunch of procedural code. Line 23 $id = $_GET['id'], line 68 $sql = "SELECT bla bla $id"; oops.

So I could give a very long list of features, but I think, that if you get the basics right, adding features later should be very easy.

1. Getting images in the gallery. That's were it all starts. Should be easy.
-Upload by web inteface. Keep original size, and resize for display. Or make it configurable what is possible. Most camera's take big pictures nowadays, so not sure if everyone wants to upload those 4Mb pictures in full size while in an internet cafe in South America.
-FTP for bigger batches?
-Is it even possible to write some javascript to resize locally first before uploading? Would speed things up in a huge way.

2. Arranging in albums. This one needs some thought I think. Because at first sight it seems easy. But in the end you need flexibility.
- So as you already say, nested albums.
- Easy re-arranging and renaming of albums.
- Place pictures in multiple albums.

3. Viewing albums and pictures. There are so many different wishes about this, that I think the most important thing to do is
- have a really easy to understand bunch of template-functions to get the albums and photos out of the db.
- And put that in a basic theme.
- Then people are able to write there own themes
- Ajax/javascript effects are nice and all, but I would be cautious to not make that a limitation (what will happen if someone doesn't want to use js?)

Your list is pretty complete. A view comments:
- URL rewriting: would be essential for me. I prefer/gallery/album/summer-holiday/bike-race over /gallery?id=7&pid=248&n=83
- Slideshow: is probably a "nice to have" but not essential. There are ways to make this possible without needing to change anything in the core. For example using jQuery magic you turn a simple list of images into a fancy gallery or slideshow, without changing anything to the html.
- Update: automated might be nice, but I think it's more important to just make it easy to upgrade. So have 2 folders, one /gallery/ , one /system/. Then for upgrading just let people delete and replace /system/. Everything customized (themes, albums, photo's, settings, etc) should go in the /gallery/ folder.

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 2:33 am
by onion2k
seodevhead wrote:Camera Raw Conversion.
RAW format is useful for post-production fixing like tweaking white balance and exposure. PHP would never be the right language for that.

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 2:46 am
by onion2k
matthijs wrote:That sounds interesting. Are there any other goals for you, besides doing more with php5?

With existing gallery systems, it's the same as with e-commerce/shopping carts: there are many out there, each with their own nice things but almost always with something missing. Most often a solid layer of code ;) If even I, with my limited programming abilities, can see that something is wrong by looking at the code, you know it's just a hacked together bunch of procedural code. Line 23 $id = $_GET['id'], line 68 $sql = "SELECT bla bla $id"; oops.
I write object oriented code (mostly) already, one of the objectives for this is for me to learn the PHP 5 extensions and features like autoloading. So, in theory at least, it'll be lovely unit tested object stuff.
matthijs wrote:So I could give a very long list of features, but I think, that if you get the basics right, adding features later should be very easy.

1. Getting images in the gallery. That's were it all starts. Should be easy.
-Upload by web inteface. Keep original size, and resize for display. Or make it configurable what is possible. Most camera's take big pictures nowadays, so not sure if everyone wants to upload those 4Mb pictures in full size while in an internet cafe in South America.
-FTP for bigger batches?
-Is it even possible to write some javascript to resize locally first before uploading? Would speed things up in a huge way.
FTP upload is a great idea. I'll be adding that to the list.
matthijs wrote:2. Arranging in albums. This one needs some thought I think. Because at first sight it seems easy. But in the end you need flexibility.
- So as you already say, nested albums.
- Easy re-arranging and renaming of albums.
- Place pictures in multiple albums.
Interesting idea, but I'm not sure how useful they'd be. I don't think I've ever seen a gallery that does any of them. Something to think about nonetheless.
matthijs wrote:3. Viewing albums and pictures. There are so many different wishes about this, that I think the most important thing to do is
- have a really easy to understand bunch of template-functions to get the albums and photos out of the db.
- And put that in a basic theme.
- Then people are able to write there own themes
- Ajax/javascript effects are nice and all, but I would be cautious to not make that a limitation (what will happen if someone doesn't want to use js?)
Those ideas make sense. They're pretty much what I was planning already. As for JS... it will always have to degrade nicely. I test with JS switched off most of the time as it is.
matthijs wrote:Your list is pretty complete. A view comments:
- URL rewriting: would be essential for me. I prefer/gallery/album/summer-holiday/bike-race over /gallery?id=7&pid=248&n=83
- Slideshow: is probably a "nice to have" but not essential. There are ways to make this possible without needing to change anything in the core. For example using jQuery magic you turn a simple list of images into a fancy gallery or slideshow, without changing anything to the html.
- Update: automated might be nice, but I think it's more important to just make it easy to upgrade. So have 2 folders, one /gallery/ , one /system/. Then for upgrading just let people delete and replace /system/. Everything customized (themes, albums, photo's, settings, etc) should go in the /gallery/ folder.
[/quote]
Again, more good points. URL rewriting is definitely a good idea, and I'd like to add it, but I realise a lot of shared account hosting doesn't offer it. I suppose it'll need to work without as well as with. Separation of my base code and user files (configuration and photos) is essential. As for automated code updates ... it's just something I've always fancied writing. It should be straight-forward ... :lol: famous last words!

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 3:22 am
by matthijs
onion2k wrote:
matthijs wrote:2. Arranging in albums. This one needs some thought I think. Because at first sight it seems easy. But in the end you need flexibility.
- So as you already say, nested albums.
- Easy re-arranging and renaming of albums.
- Place pictures in multiple albums.
Interesting idea, but I'm not sure how useful they'd be. I don't think I've ever seen a gallery that does any of them. Something to think about nonetheless.
I'm afraid I don't understand your response. What exactly do you think is (almost) never used?
What I mean in general with these 3 features is that it's important to have a good Model base, so that using the gallery you are not forever constrained to a certain design decision. But if you look at Flickr for inspiration you'll probably be aware of that. You have you data (photo's) on one side. And then how you display them is another, completely independent side. You can show them by Tags, by Albums, by Year, group them in Sets, have one photo in multiple sets if you want, etc etc.
onion2k wrote:
matthijs wrote:3. Viewing albums and pictures. There are so many different wishes about this, that I think the most important thing to do is
- have a really easy to understand bunch of template-functions to get the albums and photos out of the db.
- And put that in a basic theme.
- Then people are able to write there own themes
- Ajax/javascript effects are nice and all, but I would be cautious to not make that a limitation (what will happen if someone doesn't want to use js?)
Those ideas make sense. They're pretty much what I was planning already. As for JS... it will always have to degrade nicely. I test with JS switched off most of the time as it is.
Ok, that's a good thing.
onion2k wrote:Again, more good points. URL rewriting is definitely a good idea, and I'd like to add it, but I realise a lot of shared account hosting doesn't offer it. I suppose it'll need to work without as well as with. Separation of my base code and user files (configuration and photos) is essential. As for automated code updates ... it's just something I've always fancied writing. It should be straight-forward ... :lol: famous last words!
And what about php based URL rewriting/routing? No specific need for htaccess.
Automated updates would be interesting to tackle. I think a common problem is that it often means making files or directories writable and therefore less secure.

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 3:58 am
by onion2k
matthijs wrote:I'm afraid I don't understand your response. What exactly do you think is (almost) never used?
What I mean in general with these 3 features is that it's important to have a good Model base, so that using the gallery you are not forever constrained to a certain design decision. But if you look at Flickr for inspiration you'll probably be aware of that. You have you data (photo's) on one side. And then how you display them is another, completely independent side. You can show them by Tags, by Albums, by Year, group them in Sets, have one photo in multiple sets if you want, etc etc.
I see what you mean. I'm still not really convinced Sets is a particularly useful addition though. If you tag a bunch of images "Set 1" you get the same effect. It seems silly to add features like Sets when you can do that instead (to me). I guess it depends whether you think tags should be semantically relevant to the image or if they're just a method of organising things I suppose.

Gives me an idea though ... how about chucking all the conventional methods of organising images in the bin and only using tags. If an image was automatically tagged with the name of the owner, the date it was uploaded, the name of the album it was put in, etc ... then you could do all the conventional ways of listing photos using just tags. You'd view "all photos tagged with 'owner - onion'" and get my gallery. But ... that way you could also view "all photos tagged 'owner - onion' and 'owner - matthijs' that also have the tag 'color - blue' but do not have the tag 'subject - car'" to get a custom gallery containing all photos you and I have take of blue things that aren't cars. How powerful would that be?! That'd be awesome.

Stackable tag filtering with boolean operation.

I love it!

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 4:37 am
by matthijs
You've got it!! :D

That's exactly what I mean. Don't pay any attention to me using names like "Sets" or "albums" or whatever. These names are not important. What is important is that you think about the way your data is going to be stored and how you're going to be able to pull that out in many sorts of ways.

Your idea of using only tags could therefore be spot on. Also look at how Gmail handles your email. Your inbox is in fact just a "Label" inbox. Your outbox is just a label Outbox. Besides those you are free to add as many labels to any message as you want. And then when you go search for for example one of your contacts, all messages related to that contact are shown as well. Or you view a message, and all messages in that conversation are shown (secretly they all have a label for that conversation, I don't know the technicalities of how gmail does that).

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 3:02 pm
by Christopher
The all tags idea sounds really good.

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 3:16 pm
by seodevhead
Here's a cool idea...

Let users select a bunch of images together and automatically create an animated gif.

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 3:32 pm
by onion2k
seodevhead wrote:Let users select a bunch of images together and automatically create an animated gif.
Why?

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 3:39 pm
by seodevhead
Because if there is one thing I've always been asked about and asked to do for clients, it's one thing. MAKE ME AN ANIMATED BANNER AD! If people could just make their own banners and upload them to a site and just tell the site what pics and in what order to make the banner ad in... with the timed intervals.... I think there would be a TON of non-tech savvy people that would find that cool.

Everyone can put together an image... few people know how to make it an animated banner.

Just throwing thought's out there.

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 3:45 pm
by onion2k
Right. Sounds like a job for a dedicated 'banner making' application to be honest rather than a feature for a photo gallery.

If you're interested, there's a little app on this site - http://gifs.hu/ (warning, annoying pop-under advert) - called GifBuilder that can take a number of uploaded gifs and make them into an animated image. I've got a copy of the gifMerge class it's based on kicking around somewhere. I don't think GifBuilder can do timings, but it shouldn't be too hard to add it.

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 3:51 pm
by seodevhead
Yea I'm just spit balling here.

Re: A PHP Photo Gallery

Posted: Wed Apr 16, 2008 3:58 pm
by onion2k
I've had a quick look at GifBuilder and it can control the timings of each frame, so basically it does exactly what your clients want.