Login   Register  
PHP Classes
elePHPant
Icontem

File: resize.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Rodrigo Brandão  >  Image Handling  >  resize.php  >  Download  
File: resize.php
Role: Example script
Content type: text/plain
Description: Example
Class: Image Handling
Resize, crop and add watermarks to images
Author: By
Last change:
Date: 2011-01-17 10:58
Size: 1,141 bytes
 

Contents

Class file image Download
<?php
require_once("image.class.php");
if(isset(
$_FILES["imagem"])) {
    
$img = new image;
    
$img->source($_FILES["imagem"]);
    
// validade
    
$img->validate_extension();
    
$img->validate_dimension(4000,4000);
    
$img->validate_size(2000);
    
// get errors
    
$erros $img->error();
    if(
count($erros) == 0) {
        
$img->resize(800,NULL);
        
//$img->watermark("watermark.gif",60,"bottom","right");
        
$img->create("resize.jpg");
    }
}
?><!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>resize</title>
</head>
<body>
<center>
    <form method="post" enctype="multipart/form-data">
        select a image
        <input name="imagem" type="file" size="25">
        <input type="submit" value="Submit">
    </form>
    <br>
    <?php if(isset($erros) && count($erros) != 0) : ?>
        <?php foreach($erros as $erro) : ?>
            <font color="#FF0000"><?php echo $erro ?></font><br>
        <?php endforeach; ?>
        <br>
    <?php endif; ?>
    <?php if(file_exists("resize.jpg")) : ?>
        <a href="crop.php">click here to crop the image</a><br>
        <br>
        <img src="resize.jpg">
    <?php endif ?>
</center>
</body>
</html>