pickles/classes/ImageUtils.php
Josh Sherman 046d265347 Added the new classes and stuff.
git-svn-id: http://svn.cleancode.org/svn/pickles@30 4d10bc64-7434-11dc-a737-d2d0f8310089
2008-07-12 23:28:44 +00:00

51 lines
1.2 KiB
PHP
Executable file

<?php
class ImageUtils {
static function check($type, $types = array('image/jpeg', 'image/gif', 'image/png')) {
if (!is_array($types)) {
$types[0] = $types;
}
return in_array($type, $types);
}
static function move($origin, $destination) {
move_uploaded_file($origin, $destination);
imagedestroy($origin);
}
static function resize() {
}
static function convert($original, $destination, $keep_original = true) {
var_dump('convert ' . $original . ' ' . $destination);
var_dump( exec('convert ' . $original . ' ' . $destination) );
}
/*
if ($_FILES['image']['type'] == 'image/jpeg') {
$original = $directory . 'original.jpg';
$source = imagecreatefromjpeg($original);
list($width, $height) = getimagesize($original);
$sizes = array('small' => 75, 'medium' => 150, 'large' => 500);
foreach ($sizes as $name => $size) {
$temp = imagecreatetruecolor($size, $size);
imagecopyresampled($temp, $source, 0, 0, 0, 0, $size, $size, $width, $height);
imagejpeg($temp, "{$directory}{$name}.jpg", 85);
imagedestroy($temp);
}
imagedestroy($source);
*/
}
?>