mirror of
https://github.com/pierre42100/comunic
synced 2025-06-20 17:15:19 +00:00
First commit
This commit is contained in:
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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user