PHP Classes

File: Example.php

Recommend this page to a friend!
  Classes of Rael Antônio Carneiro Vaz   Imagens GD   Example.php   Download  
File: Example.php
Role: Example script
Content type: text/plain
Description: example documentation
Class: Imagens GD
Resize and add watermarks to images
Author: By
Last change: Simplification of code
Date: 6 years ago
Size: 929 bytes
 

Contents

Class file image Download
<?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);
?>