Site icon RibosoMatic

Marca de agua (watermark) en tus imágenes con PHP

PHPImageWorkshop  es una clase que usa la librería gráfica GD para manejo de imágenes con PHP. La clase trabaja similar a un software de edición, tipo Photoshop ó GIMP: te permite superponer muchas capas ó grupos de capas, cada una de las cuales tiene una imagen de fondo.

La clase es completamente flexible: permite superposición de infinidad de imágenes (así añadir una marca de agua), girar la imagen (y no solo 45 ó 90º), cambiar el tamaño, recortarla (thumbnail).

Uso básico

// We initialize a layer object which contains the norway picture as background
$norwayLayer = new ImageWorkshop(array(
    "imageFromPath" => "/path/to/images/norway.jpg",
));
// We initialize a layer object which contains the watermark as background
$watermarkLayer = new ImageWorkshop(array(
    "imageFromPath" => "/path/to/images/watermark.png",
));
// We add the watermark in the sublayer stack of $norwayLayer
$norwayLayer->addLayer(1, $watermarkLayer, 12, 12, "LB");
// Show image in navigator ...
$image = $norwayLayer->getResult(); // This is the generated image !
header('Content-type: image/jpeg');
imagejpeg($image, null, 95); // We choose to show a JPG with a quality of 95%
exit;

Una muestra

Enlace | PHPImageWorkshop