Module devel: View alternate image sizes (as from G2)
jnash
Joined: 2004-08-02
Posts: 814 |
Posted: Wed, 2012-05-23 17:11 |
Working on a new module to allow a block (both under photo and sidebar [configurable]) to provide links for different resolutions of the photo... This is a 'resize' of the photo on-the-fly, not just a dimensions adjustment of the fullsize... Looking for ideas/input/feedback/etc. (and if any interest in pursuing) Here is a screeny: [img]http://codex.gallery2.org/images/thumb/6/6b/Resizes.jpg/800px-Resizes.jpg[/img] |
|
Posts: 8339
And you are storing these on-the-fly resizes for future views correct?
What a nightmare it would be to rebuild every time - many many many wasted cycles.
-s
Posts: 814
I was thinking of that... for now, no, I'm wasting cycles cycles seem to be cheaper than storage, in my tests at least. A 12mb image takes milliseconds to process... (although I haven't timed it for sure)
Posts: 8339
Imagine 20 people viewing your images simultaneously 40ppl, 100ppl... !!!google bot!!!
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 814
You've got a point on that. It'd be easy enough to do, perhaps I'll make it a configurable option. Thanks for the input!
What do you think about expiring/purging them out after a set time as well? Would potentially help with any storage constraints...
Posts: 8339
Once they are built they should stay.
Storage is cheap, and not like site admins could not go into var/resizes and manually delete them.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 814
I'll probably load test this against a script I have for simulating traffic and see what the results are. I think the biggest impact is just the loading of the original image, which would happen regardless if loading a previously stored image... maybe not though, as the resized imaged would theoretically be smaller in file size.
Posts: 8339
G2 allowed admin to choose image quality ie. 80%
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 814
Thanks, I've built that in as well. I'm contemplating the image storage now... My only issue is coming up with the best place to store, and best method to retrieve them. I'm not sure I want to store them in the resizes folder...
Posts: 8339
just name them 480_imagename.jpg 640_imagename.jpg 800_imagename.jpg etc. makes them easy to sort and makes it easy to reference them in your links.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 814
that's my guess too... I was thinking like 480_imageid.jpg (where imageid is the image-id naturally) and storing them in a separate directory... but I'm thinking you may be on to something storing them in the resizes folder structure.
I've also wondered what to do with the available image resizes (how many to have, what res's etc...) right now I've got an array I iterate over that contains (640,800,1024,1280) I'm thinking this could be an admin setting by checkbox for each one desired in the list?
Posts: 27300
I think the folder structure should be along the lines of how the albums, thumbs, resizes and originals images are:
var/..../<album name>/<item name.ext>
I think the album name is important to maintain so that other modules can use these as well.
How does the keep_original module do it?
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 814
Ah, good question on the 'keeporiginal' module. I'll go take a look.
EDIT: Okay, I see it... creates an 'original' folder, and stores accordingly... I think this is best then, how about you?
Posts: 814
Okay so path forward:
1) Store a copy of the resized image once created for future retrieval vice resizing it again.
a) following the keeporiginal method of storage (in a separate folder with album structures maintained)
b) naming schema will be 480_itemid.jpg (where 480 is longest dimension, itemid = item->id: all stored as jpg's for simplicity)b) naming schema will be: imagefilename_480.jpg (where 480 is the longest dimension, stored as jpg's for simplicity)
2) Upon clicking the resize link, check to see if a stored copy is available, if so return it, if not, return and store new resized
3) Admin options:
a) allow admin setting of jpeg quality percentage
b) allow admin setting of choice of dimensions, IE: [ ]640 [ ]800 [ ]1024 [ ]1280 etc... What should the options be, how many/what sizes?
c) allow storage or not of resized images? Should this be an option?
4) Need someone to build out a page for displaying the resized image... I suck at CSS/layout... PLEASE HELP!
5) Incorporate the following events for image management:
a) item_before_delete (delete accompanying resizes as well)(also delete resizesalbum if it's an album deleted)
b) delete all resizes if item_updated (no sense in trying to figure out if rotated/name changes/etc.)
i) Delete if rotated? Probably... (how? check dim's (height or width change?)) hmmmm...ii) Maybe just delete if updated?d) item_moved (move resizes as well)
Posts: 27300
Not that we should copy anybody...
Picassa Desktop Image Sizes
320
480
640
800
1024
1200
1600
I think that something bigger than 1024 would be helpful as screen sizes are getting bigger.
Not sure if the 320 is a bit big for mobile device or not.
I can't see needing more than 5. Go with what is easy for coding and we can extend rethink later.
Im sure you will get more feedback as users use it.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 8339
let the admin set the sizes like in G2
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 814
can you post a screen shot, or explain? I'm planning on it being selectable, just wanted to know how many and what sizes... (like dave shows above)
Posts: 27300
Table of how it is in G2 attached.
just view with browser without the .txt extension.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 814
Perfect, thanks.