Вход Регистрация
Файл: _core/_class/image.php
Строк: 69
<?php

    
# mark core  v1.0
    # author Drk in
    # date 25.11.19 

    # class image

    
class image {

        var 
$image; var $type;  # global 

        
function load ($file,$type# load file
        
{
        
        
$info getimagesize($file); $this->type $info[2];
        if (
$this->type == IMAGETYPE_JPEG)$this->image imagecreatefromjpeg($file);
        if (
$this->type == IMAGETYPE_GIF )$this->image imagecreatefromgif($file);    
        if (
$this->type == IMAGETYPE_PNG )$this->image imagecreatefrompng($file);    

        }

        function 
save ($file$type IMAGETYPE_PNG$compression 90$permissions null# save file
        
{

        if (
$type == IMAGETYPE_JPEG)imagejpeg($this->image,$file,$compression);    
        if (
$type == IMAGETYPE_GIF )imagegif($this->image,$file);
        if (
$type == IMAGETYPE_PNG ):imagealphablending($this->imagefalse);imagesavealpha($this->imagetrue);imagepng($this->image,$file);endif;
        if (
$permissions != null)chmod($file,$permissions);    

        }    

        function 
width ($file# get widthw file
        
{

        return 
imagesx($this->image);    

        }    

        function 
height ($file# get widthw file
        
{

        return 
imagesy($this->image);    

        }

        function 
resize ($width,$height# resize file 
        
{

        
$new imagecreatetruecolor($width$height);
        if (
$this->type == IMAGETYPE_PNG):imagealphablending($newfalse);imagesavealpha($newtrue); endif;
        if (
$this->type == IMAGETYPE_GIF):
        
$transparent_index imagecolortransparent($this->image);
        
$transparent_color imagecolorsforindex($this->image$transparent_index);
        
$transparent_index imagecolorallocate($new$transparent_color['red'], $transparent_color['green'],
        
$transparent_color['blue']);
        
imagefill($new00$transparent_index);
        
imagecolortransparent($new$transparent_index);        
        endif;    
        
imagecopyresampled($new$this->image0000$width$height$this->width(), $this->height());
        
$this->image $new;

        }    
        
    }    
?>
Онлайн: 0
Реклама