views:

35

answers:

1

Hi guys,

I'm using phpThumb in a script to clean my images and add a watermark to them. We have images of very different sizes (from 100px width to 800px), so no matter what watermark image I use, it's either going to look too small or too big on the image.

Do you know of a way to tell phpThumb to resize the watermark? Or is there a way to resize the watermark image (depending on size of image being watermarked)?

Thanks a lot guys! Ali

A: 

I am facing the same issue.

Maybe you could put some if statements in the phpthumb.config file in the DEFAULT PARAMETER SECTION

then depending on the height and width parameters you can decide to use different files with varying sizes for the watermark.

make sure you change $PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE to false

This is not perfect cause you could not know the source image size to start with.

but it would be a better fit based on the parameters passed to phpthumb.

I guess the only other solution would be to use phpthumb as an object but that would require a lot of work.

webgr
hey webgr, thanks for your response. It's funny, I used that exact method to quickly put it together, but I don't really consider it a solution :) I suppose if you were anal enough, you could use phpThumb once to resize the watermark to the exact dimensions you wanted based on the current image you're watermarking, and do it up like that. What do you think?
Ali
If your functional requirements are flexible you could apply the watermark at the time of upload. then you could take into account the actual size of the image and - as you suggest - resize the watermark accordingly. In our case we wanted to keep the source image intact - e.g. in case we want to change our watermark in the future. Be careful about $PHPTHUMB_DEFAULTS_GETSTRINGOVERRIDE. It did not seem to work for us - you could override the wmi filter from the URL. I had to unset the GET parameter in the config file to ensure this would be tamper proof.
webgr