I’m working on a gallery site and want to add watermark to each image
(image manipulation is fairly straightforward with RMagick). I also want
to allow the administrator to change the watermark image.
The workflow I want to achieve is something like this (assume the user
has just clicked the “watermark” link in admin panel):
- Have the current watermark image shown along with a one or two
example images with watermark added to them.
- Upload a new watermark.
- Have it shown, with examples (with indication that this is temporary
and needs to be applied).
4a. Go to 2.
4b. Revert to old watermark (cancel).
4c. Apply the new watermark to all pictures (which starts a background
process for updating all photos from “clear” originals).
The problem I have is storing the temporary image between steps 2 and 4.
The ideas I have are:
- Store the image on disk as a tmp-watermark.png file and if it is
present, the admin panel knows it’s a “temporary” state. It has the
disadvantage that only one user can work on this (which is the case
anyway, but I don’t like it) and that the state is persistent, ie. if
the user uploads the file, goes away and logs in a week later, the panel
still shows the temporary watermark waiting for being approved or
- Store the image under unique name and keep the name in session.
Session times out, on the next log-in everything looks fine, there could
be two administrators working at the same time provided that I put some
locking mechanism (versioning for example, as in AR). There is no way to
clean up other than having a cron job sweeping periodically.
- Store the image using backgroundrb, I’m using it anyway for the
Do you have any ideas or some arguments for one of them? I currently
sway towards the third solution, though it requires some more research
on my part.