for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the Divergence package.
*
* @author Henry Paradiz <[email protected]>
* @copyright 2018 Henry Paradiz <[email protected]>
* @license MIT For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
* @since 1.1
*/
namespace Divergence\Models\Media;
use Exception;
* Image Media Model
* @author Chris Alfano <[email protected]>
* {@inheritDoc}
class Image extends Media
{
// configurables
public static $jpegCompression = 90;
public function getValue($name)
switch ($name) {
case 'ThumbnailMIMEType':
switch ($this->MIMEType) {
case 'application/psd':
return 'image/png';
case 'image/tiff':
return 'image/jpeg';
default:
return $this->MIMEType;
}
// no break
case 'Extension':
return 'psd';
return 'tif';
case 'image/gif':
return 'gif';
case 'image/jpeg':
return 'jpg';
case 'image/png':
return 'png';
throw new Exception('Unable to find photo extension for mime-type: '.$this->MIMEType);
return parent::getValue($name);
// public methods
// static methods
public static function analyzeFile($filename, $mediaInfo = [])
if (!$mediaInfo['imageInfo'] = @getimagesize($filename)) {
throw new Exception('Failed to read image file information');
// store image data
$mediaInfo['width'] = $mediaInfo['imageInfo'][0];
$mediaInfo['height'] = $mediaInfo['imageInfo'][1];
$mediaInfo['duration'] = 0;
return $mediaInfo;