From -180 to 180, with a default value of '0'. ' watermark.rotate' - sets the amount of rotation for the watermark image. ' watermark.opacity' - is set on a scale from 0 (transparent) to 100 (opaque). The example below moves the watermark down () by 23% from the north position: The default compass position is northwest (top left) and can be changed to any compass location, or center. ' ' - sets the starting point for shifting the x & y values. You can use either pixels or percent (%), as either positive or negative values. ' ' - sets the distance from the left and ' ' sets the distance from the top. &=35%&watermark.opacity=55%&=80%&=110%&watermark.rotate=-35Īlternatively, watermarks can be located elsewhere, with a choice of three options. The ' tile' setting repeats the watermark across the image:Ĭombine it with other settings to achieve the example below: ' watermark.position' - sets the position of the watermark as either 'center', 'tile' or the point on a compass: 'north', 'northeast', 'northwest', 'south', 'southeast', 'southwest', 'east', 'west'. Important We recommend using percentage based values if you want to deliver high quality retina images to your visitors with the help of Sirv.js. You can also choose 'fit' to fit inside the specified width/height, 'fill' to fill the width/height (and spill over) or 'ignore' to stretch the watermark. The default 'noup' will not upscale the watermark beyond its original size. I hope this helps the confused watermarkers out there.' ' - sets how the watermark scales when both and are set. If you do watermarking 'behind-the-scenes', it doesn't really matter about file size and you can get much better quality from the PNG-24 watermark, using imagecopy. Using imagecopymerge with PNG-8 watermarks is quite good for 'on-the-fly' watermarking, as the watermark file is tiny. With this one: imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height) You can replace this line: imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100) Transparency Dither: Diffusion Transparency Dither, 100%Īnd for other's benefits, this is the watermark code I have that works: Īfter a bit more reading ( this comment on the same article), I found out that you CAN use PNG-24 watermarks but with imagecopy instead of imagecopymerge. Settings: File Format: PNG-8, non-interlaced Recommended that you use "Save for Web" command with the following If you are using Adobe Photoshop to create watermark images, it is The imagecopymerge function does not properly handle the PNG-24 The watermark image should be in one of the following recommended Here is the relevant section about PNG types from this blog: It's not an issue with the application code, it's with the watermark image (PNG) itself.Ī lot of watermark examples/tutorials say to use a PNG-24 watermark, but according to a blog I've just read, they say that imagecopymerge does not deal with PNG-24 files very well, therefore, use PNG-8 and some special 'Save for Web' settings. Surely this can't be that difficult? Any ideas what I'm doing wrong? I loaded the watermark in my browser (raw) and it's definitely transparent but just not on the image. I tried setting headers and output to PNG instead but still no luck. I've just read another SO question and one of the answers advised that it won't be transparent if you don't add these two lines: imagealphablending($image, false) I know this has been covered PLENTY of times but I keep trying different scripts and modifying the one I have, and I still can't get my PNG-24 watermark.png to be transparent over the top of my parent image.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |