Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Building a Web App with Symfony 2: Finalizing
Oct 29, 2013 @ 16:49:01

On SitePoint's PHP blog they've posted the last part of their series about building a web application with the Symfony2 framework. In this latest part they cover a few more complex things you can do to add features to your application.

In Part 1 and Part 2 of this series, I have covered the basics of using Symfony 2 to develop a functioning web site. In this part of the tutorial, I will cover some more advanced techniques and finish the project with pagination, image watermarks and NativeQuery.

He uses the default image library to add the watermarks (GD) and adds in a new route to view the cover of the book with the watermark applied. He shows how to add simple pagination into the book listing page (via controller attributes) and the use of the NativeQuery Doctrine provides to do more complex queries.

tagged: symfony2 application tutorial series pagination watermark nativequery

Link: http://www.sitepoint.com/building-web-app-symfony-2-finalizing/

PHPMaster.com:
Adding Text Watermarks with Imagick
Dec 31, 2012 @ 15:15:48

On PHPMaster.com there's a recent tutorial from Martin Psinas about how you can add text to an image with the help of Imagick, the image editing software that's available to PHP via an extension.

In a previous article, Timothy Boronczyk wrote about how to create watermarks with Imagick using an overlay image. In this article, I’ll show you how to achieve a similar effect using plain text.

He takes a sample image (a headshot) and offers two versions of the same functionality - both the shell command (using "convert") and the PHP code that sets up the font to use, adds placement and pushes the result back out as a PNG. He also includes two other types of overlay - a font mask for a more see-through look and a tiled version, overlaying the text all over the image.

tagged: watermark imagick tutorial text overlay mask tile

Link:

PHPMaster.com:
Watermarking Images
Jan 02, 2012 @ 18:43:44

PHPMaster.com has a recent tutorial showing how to use the built-in Imagick extension to watermark your images effectively. It talks about what makes a good watermark and how to superimpose one on your images with a bit of sample code.

Imagine a friend of yours approaches you one day and would like you to build her a website so she can showcase her photography. She wants to be able to easily upload her photographs and have them watermarked so that people can’t easily steal them. “Don’t worry!” you tell her, because you know there are functions provided by the Imagick extension that makes watermarking images a breeze in PHP.

He talks about things like watermark transparency, the size of it (how much of the image you want it to cover) and the contrast of the watermark image to make it stand out from the image enough to be useful. Their example image and script puts the PHPMaster.com logo over the center of the image and includes a bit of code showing how to scale the watermark image to fit the image (this versus this.

tagged: watermark image tutorial superimpose

Link:

Martin Psinas' Blog:
Watermarking with text and ImageMagick
Oct 04, 2011 @ 16:44:35

Martin Psinas has submitted a new tutorial he's written up (complete with sample code) showing how to watermark an image with ImageMagick.

In my most recent venture with PHPMaster I was asked to write an article about watermarking images with PHP using ImageMagick. Virtually no documentation exists on the PHP API, although there are plenty of command-line examples from the official ImageMagick website. I spent a solid day and a half attempting to convert command-line code into PHP before (due to miscommunication) the topic was covered by someone else and my work was no longer needed. Although disappointed, it gave me something to blog about! Yay.

His script is pretty straight forward - it loads a sample image, sets up some watermark text and applies it with a "gravity" setting of "southwest" and adds it to the image (annotateImage). The output is pushed back out as a JPEG image. Also included is a slightly more complex example showing how to give the watermark an embossed look and a "text all over the image" look to prevent use of any part of the image, not just one section.

tagged: watermark text image tutorial imagemagick emboss

Link:

Script-Tutorials.com:
Watermark processing on images using PHP and GD
Sep 09, 2011 @ 17:36:06

On the Script-Tutorials blog today there's a new tutorial posted showing you how to easily add watermarks to your images dynamically, either as a part of a cache generation or on upload.

I will show you how to use GD library. And, main task today is adding watermark to image and generate result as PNG image into browser. We will using PHP and GD library. This is nice library to work with images at server side. Also (as additional tasks) I will draw little frame over image and will draw some text. Between, you can use this method (of adding watermarks in realtime) to protect original photos.

Full code for the script is included in the post, showing the combining of two images into the one finished product. The code is also available for download if you'd like to get hacking right away.

tagged: watermark image gd combine tutorial

Link:

Gonzalo Ayuso's Blog:
Watermarks in our images with PHP and Gearman
Mar 07, 2011 @ 18:12:17

Gonzalo Ayuso had previously shown how to dynamically add watermarks to your images with the help of a mod_rewrite rule. One of the side effects of this is that, with a high load on your server, things can get bogged down quite quickly. His alternative? Add the watermarks to your images with Gearman workers.

In this second solution I will use a gearman worker to generate the watermarks. The benefits of gearman is the possibility of use a pool of workers. We can add/remove workers if our application scales. Those workers can be placed even at different hosts, and we can swap easily from one configuration to another.

He includes some sample scripts to illustrate the process - a Gearman client that'll call the watermarking process and a worker that takes in the image and transforms it with GD to add a new layer for the watermark.

tagged: watermark image tutorial gearman worker client

Link:

Gonzalo Ayuso's Blog:
Watermarks in our images with PHP and mod_rewrite
Mar 01, 2011 @ 14:36:21

Gonzalo Ayuso has a new tutorial posted to his site today showing how to use mod_rewrite and a little bit of PHP magic to watermark images without having to apply it to each one manually.

he idea is simple. Instead of opening directly the image, we are going to open a PHP script. This PHP script will open the original image file with imagecreatefromjpeg, add the footer and flush the new image to the browser with the properly headers.

Since it would be a lot of trouble (especially on a larger site) to have to rewrite all of the <img> tags to point to this new PHP script for adding the watermark, he opts for the .htaccess instead. It catches and rewrites the request to the "watermark.php" file which pulls in that image, watermarks it and pushes the result back out.

tagged: watermark tutorial imagecreatefromjpeg image dynamic

Link:

Mikko Koppanen's Blog:
Choosing watermark color based on the background luminosity
Oct 13, 2007 @ 21:04:00

Mikko Koppanen has another blog entry posted dealing with image manipulation with PHP and Imagick, this time it's a cool little script that lets you pick your watermark's color based on the image's background luminosity.

Usually images are watermarked using a predefined color (let's say for example "white"). How well does this actually work when you're doing the watermark on a light or even a white image? The answer is simple: not very well.

His example uses the ImagickPixelIterator to check the luminosity of the background and assigns the text a value between black and white according to the background. Complete code with usage and examples of the resulting images are included.

tagged: imagick watermark color background luminosity imagick watermark color background luminosity

Link:

Mikko Koppanen's Blog:
Choosing watermark color based on the background luminosity
Oct 13, 2007 @ 21:04:00

Mikko Koppanen has another blog entry posted dealing with image manipulation with PHP and Imagick, this time it's a cool little script that lets you pick your watermark's color based on the image's background luminosity.

Usually images are watermarked using a predefined color (let's say for example "white"). How well does this actually work when you're doing the watermark on a light or even a white image? The answer is simple: not very well.

His example uses the ImagickPixelIterator to check the luminosity of the background and assigns the text a value between black and white according to the background. Complete code with usage and examples of the resulting images are included.

tagged: imagick watermark color background luminosity imagick watermark color background luminosity

Link:

PHPit.net:
Image manipulation with PHP & the GD library (Part 2)
Aug 14, 2006 @ 18:39:51

New on PHPit.net today is part two of their series covering working with images in PHP through the GD graphics library.

In this second part of the "Image manipulation with PHP & the GD library" article series you will learn how to resize images, create thumbnails, watermark images and more.

They start with resizing images, showing how to grab the current size and alter it to modify the output (both in a set and proportional way). With that code in place, they take the next logical step - an automatic thumbnail creator from a file upload. Finally, they show how to help protect your images using a watermark - their example is a "Image by YourWebsite.com" string of text placed on the image.

tagged: image manipulation part2 gd watermark thumbnail resize image manipulation part2 gd watermark thumbnail resize

Link:


Trending Topics: