Вход Регистрация
Файл: system/vendor/intervention/image/src/Intervention/Image/Gd/Driver.php
Строк: 108
<?php

namespace InterventionImageGd;

use 
InterventionImageExceptionNotSupportedException;
use 
InterventionImageImage;

class 
Driver extends InterventionImageAbstractDriver
{
    
/**
     * Creates new instance of driver
     *
     * @param Decoder $decoder
     * @param Encoder $encoder
     */
    
public function __construct(Decoder $decoder nullEncoder $encoder null)
    {
        if ( ! 
$this->coreAvailable()) {
            throw new 
NotSupportedException(
                
"GD Library extension not available with this PHP installation."
            
);
        }

        
$this->decoder $decoder $decoder : new Decoder;
        
$this->encoder $encoder $encoder : new Encoder;
    }

    
/**
     * Creates new image instance
     *
     * @param  int     $width
     * @param  int     $height
     * @param  mixed   $background
     * @return InterventionImageImage
     */
    
public function newImage($width$height$background null)
    {
        
// create empty resource
        
$core imagecreatetruecolor($width$height);
        
$image = new Image(new static, $core);

        
// set background color
        
$background = new Color($background);
        
imagefill($image->getCore(), 00$background->getInt());

        return 
$image;
    }

    
/**
     * Reads given string into color object
     *
     * @param  string $value
     * @return AbstractColor
     */
    
public function parseColor($value)
    {
        return new 
Color($value);
    }

    
/**
     * Checks if core module installation is available
     *
     * @return boolean
     */
    
protected function coreAvailable()
    {
        return (
extension_loaded('gd') && function_exists('gd_info'));
    }

    
/**
     * Returns clone of given core
     *
     * @return mixed
     */
    
public function cloneCore($core)
    {
        
$width imagesx($core);
        
$height imagesy($core);
        
$clone imagecreatetruecolor($width$height);
        
imagealphablending($clonefalse);
        
imagesavealpha($clonetrue);
        
$transparency imagecolorallocatealpha($clone000127);
        
imagefill($clone00$transparency);
        
        
imagecopy($clone$core0000$width$height);

        return 
$clone;
    }
}
Онлайн: 0
Реклама