include the Zebra_Image library
require 'path/to/Zebra_Image.php';
instantiate the class
$img = new Zebra_Image();
a source image
$img->source_path = 'path/to/source.ext';
path to where should the resulting image be saved
note that by simply setting a different extension to the file will
instruct the script to create an image of that particular type
$img->target_path = 'path/to/target.ext';
rotate the image 45 degrees, clockwise
$img->rotate(45);
public rotate ( double $angle, mixed $background_color ) : boolean | ||
$angle | double | Angle by which to rotate the image clockwise. Between 0 and 360. @param mixed $background_color (Optional) The hexadecimal color (like "#FFFFFF" or "#FFF") of the uncovered zone after the rotation. When set to -1 the script will preserve transparency for transparent GIF and PNG images. For non-transparent images the background will be white in this case. Default is -1. @return boolean Returns TRUE on success or FALSE on error. If FALSE is returned, check the {@link error} property to see the error code. |
$background_color | mixed | |
return | boolean |
// and if there is an error, show the error message if (!$image->flip_both()) { show_error($image->error, $image->source_path, $image->target_path); } // indicate a target image $image->target_path = 'results/crop.' . $ext; // crop // and if there is an error, show the error message if (!$image->crop(0, 0, 50, 50)) { show_error($image->error, $image->source_path, $image->target_path); } // indicate a target image $image->target_path = 'results/rotate.' . $ext; // rotate // and if there is an error, show the error message if (!$image->rotate(45)) { show_error($image->error, $image->source_path, $image->target_path); } // indicate a target image $image->target_path = 'results/filter.' . $ext; // apply some filters // (this combination produces the "sepia" filter) $image->apply_filter(array(array('grayscale'), array('colorize', 90, 60, 40))); ?> <p>Table has background so that transparency can be observed.</p> <table style="background:#ABCDEF; border: 2px solid #666"> <tr> <td width="100" align="center">Resized to 100x100</td> <td width="100" align="center">Flipped horizontally</td> <td width="100" align="center">Flipped vertically</td> <td width="100" align="center">Flipped both horizontally and vertically</td>
<?php //SI EL ROTAR ES MAYOR A 0 SE ROTA DE LO CONTRARIO BRINCAMOS A HACER CROP if ($_REQUEST[rotar] > 0) { $imgRotate = new Zebra_Image(); $imgRotate->source_path = "../upload/temporal_{$_REQUEST['imagen']}"; $imgRotate->target_path = "../upload/temporal_{$_REQUEST['imagen']}"; $imgRotate->jpeg_quality = 100; $imgRotate->preserve_aspect_ratio = true; $imgRotate->enlarge_smaller_images = true; $imgRotate->preserve_time = true; if ($imgRotate->rotate(intval($_REQUEST[rotar]))) { require_once './crop.php'; } else { switch ($imgRotate->error) { case 1: echo 'Source file could not be found!'; break; case 2: echo 'Source file is not readable!'; break; case 3: echo 'Could not write target file!'; break; case 4: echo 'Unsupported source file format!'; break; case 5: echo 'Unsupported target file format!'; break; case 6: