Help with batch processing for website
Hello, I'm majoring in Computer Science and currently taking some programing classes.
I'm wanting to build a website where I can upload lots of pictures. I want to be able to batch process the images... resizing the photos and adding a logo to each one. I want this to be done all in the backend of the website. I worked for a company who took event photos and had its employees upload the photos through their website. The imges were automatically resized and were stamped with a logo.
I'm wanting to do something similar but not quiet (am not stealing their idea... just taking a piece of their concept). I like the idea that their employees could just upload the photos and everything else was taken care of.
As a programmer in training, I want to be able to write code to accomplish something like this.... and put it to test. The thing is that I don't even know where to start. Can anyone point me out in the right direction?
Thanks in advance....
There are many ways to do this.
Store the unaltered images, and apply watermarking on the fly (or logo/bar, whatever)
major negative being that more processing power is needed on each image request, but you could use reverse caching to speed that up and only process images when they change (i.e. when you change the logo for instance)
major advantage being that if you want to change it, you don't have to go back though the library.
Store the unaltered, generate a proxy with logo
slight negative being more space is used, given as its web, this is unlikely to amount to anything, after all a few thousand image thumbs at 1280 are still pretty small.
slight negative, in order to change them all, you'll need to rebatch run a convert
And lastly, temporarily save the original, convert, and dispose of the original
negative being that of course, should you wish to change the logos, depending on what changes you want you are likely to only be able to apply it to newer images.
Annnd now how to do it,
just check out ImageMagick and its associated language bindings, upload to a storage area - if you envisage low thoughput you probably can do this in-line and convert in the webscripting language of your choice (singular (zip file for instance) mega sized uploads are problematic, read multi GB, php-magicwand or such may be of help to apply whatever transform you could possibly comprehend), or have a background process, either cronned(or equivilent) to check if it needs to be run, and then process from the upload area - but then you have the problem of having to store metadata as to the eventual album it appears in, but of course there are a billion ways to do anything and that would depend on what you want to achieve.
Hope that puts you on one possible way forward.
Drupal + Image Picker module. This module seems to do all you are asking for: resize the image, save it as cache, watermark the resized image, and have the ability for "batch import".
P.S.- However, since you state you're a programmer in training, I'd recommend learning the Drupal API, and theming as the starting point.
Last edited by 3dmax_mouse_sux; 03-09-2012 at 04:00 AM.
How would you like to do it?
Process on the fly, process on the upload or batch everything inside a folder?
Or a semi-fly process, you could request a file like 'http://site.com/image/stuff.png' and got the php to check if the file '_optimized_stuff.png' exists, redirect to it, if it doesn't, create it and redirect. Notice you are only processing the ones you need. Btw, _optimized is just an example you should not use it, a md5('stuff.png').'.png'; would be my choice.
Just let us know what you're thinking, it's an easy job and there are already a lot of tools to do this. But still, if you want to reinvent the wheel be my guest and i'll help you the best i can.