mirror of
https://github.com/pierre42100/comunic
synced 2025-06-20 00:55:20 +00:00
First commit
This commit is contained in:
38
developer/vendor/gregwar/image/Gregwar/Image/Source/Create.php
vendored
Normal file
38
developer/vendor/gregwar/image/Gregwar/Image/Source/Create.php
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Source;
|
||||
|
||||
/**
|
||||
* Creates a new image from scratch
|
||||
*/
|
||||
class Create extends Source
|
||||
{
|
||||
protected $width;
|
||||
protected $height;
|
||||
|
||||
public function __construct($width, $height)
|
||||
{
|
||||
$this->width = $width;
|
||||
$this->height = $height;
|
||||
}
|
||||
|
||||
public function getWidth()
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
public function getHeight()
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
public function getInfos()
|
||||
{
|
||||
return array($this->width, $this->height);
|
||||
}
|
||||
|
||||
public function correct()
|
||||
{
|
||||
return $this->width > 0 && $this->height > 0;
|
||||
}
|
||||
}
|
26
developer/vendor/gregwar/image/Gregwar/Image/Source/Data.php
vendored
Normal file
26
developer/vendor/gregwar/image/Gregwar/Image/Source/Data.php
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Source;
|
||||
|
||||
/**
|
||||
* Having image in some string
|
||||
*/
|
||||
class Data extends Source
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
public function getInfos()
|
||||
{
|
||||
return sha1($this->data);
|
||||
}
|
||||
}
|
63
developer/vendor/gregwar/image/Gregwar/Image/Source/File.php
vendored
Normal file
63
developer/vendor/gregwar/image/Gregwar/Image/Source/File.php
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Source;
|
||||
|
||||
use Gregwar\Image\Image;
|
||||
|
||||
/**
|
||||
* Open an image from a file
|
||||
*/
|
||||
class File extends Source
|
||||
{
|
||||
protected $file;
|
||||
|
||||
public function __construct($file)
|
||||
{
|
||||
$this->file = $file;
|
||||
}
|
||||
|
||||
public function getFile()
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
|
||||
public function correct()
|
||||
{
|
||||
return false !== @exif_imagetype($this->file);
|
||||
}
|
||||
|
||||
public function guessType()
|
||||
{
|
||||
if (function_exists('exif_imagetype')) {
|
||||
$type = @exif_imagetype($this->file);
|
||||
|
||||
if (false !== $type) {
|
||||
if ($type == IMAGETYPE_JPEG) {
|
||||
return 'jpeg';
|
||||
}
|
||||
|
||||
if ($type == IMAGETYPE_GIF) {
|
||||
return 'gif';
|
||||
}
|
||||
|
||||
if ($type == IMAGETYPE_PNG) {
|
||||
return 'png';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$parts = explode('.', $this->file);
|
||||
$ext = strtolower($parts[count($parts)-1]);
|
||||
|
||||
if (isset(Image::$types[$ext])) {
|
||||
return Image::$types[$ext];
|
||||
}
|
||||
|
||||
return 'jpeg';
|
||||
}
|
||||
|
||||
public function getInfos()
|
||||
{
|
||||
return $this->file;
|
||||
}
|
||||
}
|
21
developer/vendor/gregwar/image/Gregwar/Image/Source/Resource.php
vendored
Normal file
21
developer/vendor/gregwar/image/Gregwar/Image/Source/Resource.php
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Source;
|
||||
|
||||
/**
|
||||
* Have the image directly in a specific resource
|
||||
*/
|
||||
class Resource extends Source
|
||||
{
|
||||
protected $resource;
|
||||
|
||||
public function __construct($resource)
|
||||
{
|
||||
$this->resource = $resource;
|
||||
}
|
||||
|
||||
public function getResource()
|
||||
{
|
||||
return $this->resource;
|
||||
}
|
||||
}
|
34
developer/vendor/gregwar/image/Gregwar/Image/Source/Source.php
vendored
Normal file
34
developer/vendor/gregwar/image/Gregwar/Image/Source/Source.php
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Gregwar\Image\Source;
|
||||
|
||||
/**
|
||||
* An Image source
|
||||
*/
|
||||
class Source
|
||||
{
|
||||
/**
|
||||
* Guess the type of the image
|
||||
*/
|
||||
public function guessType()
|
||||
{
|
||||
return 'jpeg';
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this image correct ?
|
||||
*/
|
||||
public function correct()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about images, these informations should
|
||||
* change only if the original image changed
|
||||
*/
|
||||
public function getInfos()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user