1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-17 20:28:21 +01:00

various minor fixes

This commit is contained in:
Oliver Vogel 2014-06-30 17:30:03 +02:00
parent 25aba89310
commit fc0c202772
17 changed files with 111 additions and 149 deletions

View File

@ -139,7 +139,6 @@ abstract class AbstractColor
throw new \Intervention\Image\Exception\NotReadableException(
"Color format ({$value}) cannot be read."
);
break;
}
return $this;
@ -157,31 +156,25 @@ abstract class AbstractColor
case 'rgba':
return $this->getRgba();
break;
case 'hex':
return $this->getHex('#');
break;
case 'int':
case 'integer':
return $this->getInt();
break;
case 'array':
return $this->getArray();
break;
case 'obj':
case 'object':
return $this;
break;
default:
throw new \Intervention\Image\Exception\NotSupportedException(
"Color format ({$type}) is not supported."
);
break;
}
}

View File

@ -161,35 +161,27 @@ abstract class AbstractDecoder
case $this->isGdResource():
return $this->initFromGdResource($this->data);
break;
case $this->isImagick():
return $this->initFromImagick($this->data);
break;
case $this->isInterventionImage():
return $this->initFromInterventionImage($this->data);
break;
case $this->isSymfonyUpload():
return $this->initFromPath($this->data->getRealPath());
break;
case $this->isBinary():
return $this->initFromBinary($this->data);
break;
case $this->isUrl():
return $this->initFromBinary(file_get_contents($this->data));
break;
case $this->isFilePath():
return $this->initFromPath($this->data);
break;
default:
throw new Exception\NotReadableException("Image source not readable");
break;
}
}

View File

@ -4,6 +4,34 @@ namespace Intervention\Image;
abstract class AbstractEncoder
{
/**
* Buffer of encode result data
*
* @var string
*/
public $result;
/**
* Image object to encode
*
* @var Image
*/
public $image;
/**
* Output format of encoder instance
*
* @var string
*/
public $format;
/**
* Output quality of encoder instance
*
* @var integer
*/
public $quality;
/**
* Processes and returns encoded image as JPEG string
*
@ -32,20 +60,13 @@ abstract class AbstractEncoder
*/
abstract protected function processTiff();
/**
* Buffer of encode result data
*
* @var string
*/
public $result;
/**
* Process a given image
*
* @param Image $image
* @param string $format
* @param integer $quality
* @return Intervention\Image\Image
* @return Image
*/
public function process(Image $image, $format = null, $quality = null)
{
@ -86,7 +107,6 @@ abstract class AbstractEncoder
throw new \Intervention\Image\Exception\NotSupportedException(
"Encoding format ({$format}) is not supported."
);
break;
}
return $image->setEncoded($this->result);
@ -108,7 +128,7 @@ abstract class AbstractEncoder
/**
* Sets image to process
*
* @param Intervention\Image\Image $image
* @param Image $image
*/
protected function setImage($image)
{

View File

@ -4,6 +4,55 @@ namespace Intervention\Image;
abstract class AbstractFont
{
/**
* Text to be written
*
* @var String
*/
public $text;
/**
* Text size in pixels
*
* @var integer
*/
public $size = 12;
/**
* Color of the text
*
* @var mixed
*/
public $color = '000000';
/**
* Rotation angle of the text
*
* @var integer
*/
public $angle = 0;
/**
* Horizontal alignment of the text
*
* @var String
*/
public $align;
/**
* Vertical alignment of the text
*
* @var String
*/
public $valign;
/**
* Path to TTF or GD library internal font file of the text
*
* @var mixed
*/
public $file;
/**
* Draws font to given image on given position
*

View File

@ -7,7 +7,7 @@ class Argument
/**
* Command with arguments
*
* @var Intervention\Image\Commands\AbstractCommand
* @var AbstractCommand
*/
public $command;

View File

@ -43,9 +43,8 @@ class Decoder extends \Intervention\Image\AbstractDecoder
default:
throw new \Intervention\Image\Exception\NotReadableException(
"Unable to read image type ({$this->type}) only use JPG, PNG or GIF images with GD driver."
"Unable to read image type. Only use JPG, PNG or GIF images with GD driver."
);
break;
}
// build image

View File

@ -9,8 +9,8 @@ class Driver extends \Intervention\Image\AbstractDriver
/**
* Creates new instance of driver
*
* @param Intervention\Image\Gd\Decoder $decoder
* @param Intervention\Image\Gd\Encoder $encoder
* @param Decoder $decoder
* @param Encoder $encoder
*/
public function __construct(Decoder $decoder = null, Encoder $encoder = null)
{
@ -36,8 +36,7 @@ class Driver extends \Intervention\Image\AbstractDriver
{
// create empty resource
$core = imagecreatetruecolor($width, $height);
$size = new Size($width, $height);
$image = new \Intervention\Image\Image(new self, $core, $size);
$image = new \Intervention\Image\Image(new self, $core);
// set background color
$background = new Color($background);

View File

@ -6,55 +6,6 @@ use \Intervention\Image\Image;
class Font extends \Intervention\Image\AbstractFont
{
/**
* Text to be written
*
* @var String
*/
protected $text;
/**
* Text size in pixels
*
* @var integer
*/
protected $size = 12;
/**
* Color of the text
*
* @var mixed
*/
protected $color = '000000';
/**
* Rotation angle of the text
*
* @var integer
*/
protected $angle = 0;
/**
* Horizontal alignment of the text
*
* @var String
*/
protected $align;
/**
* Vertical alignment of the text
*
* @var String
*/
protected $valign;
/**
* Path to TTF or GD library internal font file of the text
*
* @var mixed
*/
protected $file;
/**
* Get font size in points
*

View File

@ -7,7 +7,7 @@ class Image extends File
/**
* Instance of current image driver
*
* @var Intervention\Image\AbstractDriver
* @var AbstractDriver
*/
protected $driver;
@ -21,7 +21,7 @@ class Image extends File
/**
* Image resource backup of current image processor
*
* @var mixded
* @var mixed
*/
protected $backup;
@ -35,7 +35,7 @@ class Image extends File
/**
* Creates a new Image instance
*
* @param Driver $driver
* @param AbstractDriver $driver
* @param mixed $core
*/
public function __construct(AbstractDriver $driver = null, $core = null)

View File

@ -12,14 +12,14 @@ class ImageManager
/**
* Instance of Illuminate Config respository
*
* @var Illuminate\Config\Repository
* @var \Illuminate\Config\Repository
*/
public $config;
/**
* Creates new instance of Image Manager
*
* @param Illuminate\Config\Repository $config
* @param \Illuminate\Config\Repository $config
*/
public function __construct(\Illuminate\Config\Repository $config = null)
{
@ -63,6 +63,7 @@ class ImageManager
* Initiates an Image instance from different input types
*
* @param mixed $data
*
* @return Intervention\Image\Image
*/
public function make($data)
@ -76,6 +77,7 @@ class ImageManager
* @param integer $width
* @param integer $height
* @param mixed $background
*
* @return Intervention\Image\Image
*/
public function canvas($width, $height, $background = null)

View File

@ -9,14 +9,14 @@ class ImageManagerStatic
/**
* Instance of Intervention\Image\ImageManager
*
* @var Intervention\Image\ImageManager
* @var ImageManager
*/
public $manager;
/**
* Creates a new instance
*
* @param Intervention\Image\ImageManager $manager
* @param ImageManager $manager
*/
public function __construct(ImageManager $manager = null)
{
@ -37,6 +37,7 @@ class ImageManagerStatic
* Statically initiates an Image instance from different input types
*
* @param mixed $data
*
* @return Intervention\Image\Image
*/
public static function make($data)
@ -50,6 +51,7 @@ class ImageManagerStatic
* @param integer $width
* @param integer $height
* @param mixed $background
*
* @return Intervention\Image\Image
*/
public static function canvas($width, $height, $background = null)
@ -63,6 +65,7 @@ class ImageManagerStatic
* @param Closure $callback
* @param integer $lifetime
* @param boolean $returnObj
*
* @return mixed
*/
public static function cache(Closure $callback, $lifetime = null, $returnObj = false)

View File

@ -1,7 +1,7 @@
<?php namespace Intervention\Image;
use Illuminate\Support\ServiceProvider;
use Illuminate\Http\Response;
use Illuminate\Http\Response as IlluminateResponse;
class ImageServiceProvider extends ServiceProvider
{
@ -89,7 +89,7 @@ class ImageServiceProvider extends ServiceProvider
$mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $content);
// return http response
return new Response($content, 200, array(
return new IlluminateResponse($content, 200, array(
'Content-Type' => $mime,
'Cache-Control' => 'max-age='.($config->get('imagecache::lifetime')*60).', public',
'Etag' => md5($content)

View File

@ -7,7 +7,7 @@ class Color extends \Intervention\Image\AbstractColor
/**
* ImagickPixel containing current color information
*
* @var ImagickPixel
* @var \ImagickPixel
*/
public $pixel;
@ -57,6 +57,7 @@ class Color extends \Intervention\Image\AbstractColor
* Initiates color object from given string
*
* @param string $value
*
* @return Intervention\Image\AbstractColor
*/
public function initFromString($value)
@ -70,6 +71,7 @@ class Color extends \Intervention\Image\AbstractColor
* Initiates color object from given ImagickPixel object
*
* @param ImagickPixel $value
*
* @return Intervention\Image\AbstractColor
*/
public function initFromObject($value)
@ -85,6 +87,7 @@ class Color extends \Intervention\Image\AbstractColor
* @param integer $r
* @param integer $g
* @param integer $b
*
* @return Intervention\Image\AbstractColor
*/
public function initFromRgb($r, $g, $b)
@ -99,6 +102,7 @@ class Color extends \Intervention\Image\AbstractColor
* @param integer $g
* @param integer $b
* @param float $a
*
* @return Intervention\Image\AbstractColor
*/
public function initFromRgba($r, $g, $b, $a)
@ -125,6 +129,7 @@ class Color extends \Intervention\Image\AbstractColor
* Calculates hexadecimal value of current color instance
*
* @param string $prefix
*
* @return string
*/
public function getHex($prefix = '')
@ -236,7 +241,7 @@ class Color extends \Intervention\Image\AbstractColor
/**
* Initiates ImagickPixel from given RGBA values
*
* @return ImagickPixel
* @return \ImagickPixel
*/
private function setPixel($r, $g, $b, $a = null)
{
@ -250,7 +255,7 @@ class Color extends \Intervention\Image\AbstractColor
/**
* Returns current color as ImagickPixel
*
* @return ImagickPixel
* @return \ImagickPixel
*/
public function getPixel()
{

View File

@ -9,8 +9,8 @@ class Driver extends \Intervention\Image\AbstractDriver
/**
* Creates new instance of driver
*
* @param Intervention\Image\Imagick\Decoder $decoder
* @param Intervention\Image\Imagick\Encoder $encoder
* @param Decoder $decoder
* @param Encoder $encoder
*/
public function __construct(Decoder $decoder = null, Encoder $encoder = null)
{
@ -44,10 +44,8 @@ class Driver extends \Intervention\Image\AbstractDriver
$core->setColorspace(\Imagick::COLORSPACE_UNDEFINED);
$core->setImageColorspace(\Imagick::COLORSPACE_UNDEFINED);
$size = new Size($width, $height);
// build image
$image = new \Intervention\Image\Image(new self, $core, $size);
$image = new \Intervention\Image\Image(new self, $core);
return $image;
}

View File

@ -6,55 +6,6 @@ use \Intervention\Image\Image;
class Font extends \Intervention\Image\AbstractFont
{
/**
* Text to be written
*
* @var String
*/
protected $text;
/**
* Text size in pixels
*
* @var integer
*/
protected $size = 12;
/**
* Color of the text
*
* @var mixed
*/
protected $color = '000000';
/**
* Rotation angle of the text
*
* @var integer
*/
protected $angle = 0;
/**
* Horizontal alignment of the text
*
* @var String
*/
protected $align;
/**
* Vertical alignment of the text
*
* @var String
*/
protected $valign;
/**
* Path to TTF or GD library internal font file of the text
*
* @var mixed
*/
protected $file;
/**
* Draws font to given image at given position
*

View File

@ -7,7 +7,7 @@ class Response
/**
* Image that should be displayed by response
*
* @var Intervention\Image\Image
* @var Image
*/
public $image;

View File

@ -23,7 +23,7 @@ class Size
/**
* Pivot point
*
* @var Intervention\Image\Point
* @var Point
*/
public $pivot;