Файл: apwa/includes/thumb_resize.php
Строк: 57
<?php
/**
*
* @package Last X [attachments] on Forum v.0.0.4
* @version $Id: thumb_resize.php 2356 2010-02-10 00:09:52Z 4seven $
* @copyright (c) 2010 / 4seven
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
// First Topic [pic] on Forum Index / 4seven / 2010
class simpleresize {
var $image;
var $image_type;
function load($filename) {
$image_info = getimagesize($filename);
$this->image_type = $image_info[2];
if( $this->image_type == IMAGETYPE_JPEG ) {
$this->image = @imagecreatefromjpeg($filename);
} elseif( $this->image_type == IMAGETYPE_GIF ) {
$this->image = @imagecreatefromgif($filename);
} elseif( $this->image_type == IMAGETYPE_PNG ) {
$this->image = @imagecreatefrompng($filename);
}
}
function save($filename, $image_type=IMAGETYPE_JPEG, $permissions=null) {
if( $image_type == IMAGETYPE_JPEG ) {
@imagejpeg($this->image,$filename,100);
} elseif( $image_type == IMAGETYPE_GIF ) {
@imagegif($this->image,$filename);
} elseif( $image_type == IMAGETYPE_PNG ) {
@imagepng($this->image,$filename,0);
}
if( $permissions != null) {
chmod($filename,$permissions);
}
@imagedestroy($this->image);
}
function getWidth() {
return @imagesx($this->image);
}
function getHeight() {
return @imagesy($this->image);
}
function resizeToHeight($height) {
$ratio = $height / $this->getHeight();
$width = $this->getWidth() * $ratio;
@$this->resize($width,$height);
}
function resizeToWidth($width) {
$ratio = $width / $this->getWidth();
$height = $this->getheight() * $ratio;
$this->resize($width,$height);
}
function resize($width,$height) {
$new_image = @imagecreatetruecolor($width, $height);
@imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
}
}
// First Topic [pic] on Forum Index / 4seven / 2010
?>