PHP Classes

Imagens GD: Resize and add watermarks to images

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 216 All time: 8,309 This week: 455Up
Version License PHP version Categories
class_imagens 1.0.1GNU General Publi...5.6PHP 5, Graphics
Description 

Author

This class can resize and add watermarks to images.

It can take the path of a given image file and creates a thumbnail image of a given size and store it in a given directory.

The class can also apply a given watermark and apply it to the resulting thumbnail at a given position.

Picture of Rael Antônio Carneiro Vaz
Name: Rael Antônio Carneiro ... <contact>
Classes: 1 package by
Country: Brazil Brazil

Example

<?php
require ("class.imagens.php");

$thumb = new imagens;
$thumb->img_w = 80; // pixels
$thumb->img_h = 80; // pixels
$thumb->img_arquivo = 'real-path-to-file.jpg';
$thumb->img_pos_x = "center";
$thumb->img_pos_y = "center";

$thumb->salvar = true;
$thumb->salvar_diretorio = 'cache/';
$thumb->salvar_nome = $thumb->img_arquivo;

$url_file_ext = explode('.', $thumb->img_arquivo);
$url_file_ext = end($url_file_ext);
$url_file_ext = strtolower($url_file_ext);

switch (
$url_file_ext) {
 case
'gif':
 
header('Content-type: image/gif');
 break;
 case
'png':
 
header('Content-type: image/png');
 break;
 default:
 
header('Content-type: image/jpeg');
 break;
 }
 
$expires = 60*60*24*365;//(1 dia)
 
header("Pragma: public");
 
header("Cache-Control: maxage=".$expires);
 
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');
 echo
$thumb->gerar();
}
unset(
$thumb);
?>


  Files folder image Files (2)  
File Role Description
Plain text file class.imagens.php Class Image GD
Accessible without login Plain text file Example.php Example example documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:216
This week:0
All time:8,309
This week:455Up
User Comments (1)