Link to home
Start Free TrialLog in
Avatar of fionafenton
fionafentonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Watermarking using too much CPU time

On a property website I'm dynamically watermarking images using script that can be found here
http://phpexample.ucoz.com/publ/watermarks_usage/1-1-0-5
This works beautifully as we don't want to permanently watermark images as these are included in several feeds to portal sites where they apply their own watermark.

However, the hosting company are now saying that this script is using up too much CPU time.

Anyone got any ideas as to how we can overcome this?
Avatar of Hugh McCurdy
Hugh McCurdy
Flag of United States of America image

How about two copies of the images, one with the watermark and one without?
ASKER CERTIFIED SOLUTION
Avatar of Derokorian
Derokorian
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Derokorian, while yours is a variation of my answer, I like yours better.  The watermarked copy is made only if needed.  Of course, it's kept (which is my solution).  I also like your solution because it looks simple to implement and it will (almost certainly) solve the problem, as stated.

Now, if the problem is different than stated, this isn't solved.  If the watermark is supposed to contain information about the recipient, we still have a problem.

Fiona?  Are the watermarks unique to each recipient?

If they are, all I can think of is to make the code more efficient.  Perhaps run the water mark software in C if possible.
@hmccurdy I didn't want to suggest that you weren't right, I was merely showing how I implement the idea you already proposed - except to allow for as many watermarks as needed. Our solution would reduce CPU/RAM usage significantly and increase HD usage. However HD storage is a dime a gig (maybe even a dime a tera!)

@fiona another problem could be the size of the images, if the resolution is very high you could think about resizing them down to a more reasonable resolution when you upload them. IE if the image will never be displayed higher than 1024x768 why store it at 3200x2400 anyway? Especially since it will hog more resources to watermark / output.
Avatar of fionafenton

ASKER

Derokorian: Your solution is along the lines of what I had already concluded I would have to do. I was hoping there might be some other solution that I hadn't thought of. I have the additional problem that photos are often changed (but file names aren't).
I think the simplest solution is to include all this in the image upload script, which already resizes all the images and creates the folders and thumbnails. I'll just get it to create an extra folder and watermark the images at the same time. That way I can be sure that the watermarked and unwatermaked images are the same.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you both for your input. I have some code rewriting to do!
You're welcome.
Glad to help! If you need help rewriting code - feel free to post what you have and explain what you need and we'll be here!

Good luck!