diff --git a/src/Commands/ResizeImages.php b/src/Commands/ResizeImages.php index 4d03ce8..c280c2b 100644 --- a/src/Commands/ResizeImages.php +++ b/src/Commands/ResizeImages.php @@ -1,16 +1,16 @@ imageFile->fullpath); + \Log::info('ImageResizer for queue: '.$this->imageFile->fullpath); - // Initialize InterImage Instance first + // Initialize InterImage Instance first $this->interImage = new InterImage; - $sizes = $this->type_config['sizes']; + $sizes = $this->type_config['sizes']; $compiled_path = $this->type_config['compiled']; $filename = $this->imageFile->filename; @@ -89,7 +89,7 @@ public function handle() $this->resizeImage($this->imageFile->fullpath, $target, $size); } } - } + } public function resizeImage($fullpath, $target, $size) diff --git a/src/ImageFile.php b/src/ImageFile.php index 63876cd..b46846c 100644 --- a/src/ImageFile.php +++ b/src/ImageFile.php @@ -33,6 +33,13 @@ class ImageFile * @var string */ public $extension; + + /** + * File extension of current file + * + * @var string + */ + public $size = []; /** * File name of current file @@ -68,6 +75,7 @@ public function setFileInfoFromPath($path) $this->extension = array_key_exists('extension', $info) ? $info['extension'] : null; if (file_exists($path) && is_file($path)) { + $this->size = getimagesize($path); $this->mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path); } @@ -90,6 +98,27 @@ public function filesize() return false; } + /** + * Get image file size + * + * @return mixed + */ + public function sizes() + { + if(empty($this->size)){ + $path = $this->fullpath; + + if (file_exists($path) && is_file($path)) { + $this->size = getimagesize($path); + return $this->size; + } + } + else { + return $this->size; + } + return false; + } + /** * Get file path by string * @@ -97,7 +126,7 @@ public function filesize() */ public function __toString () { - return $this->getFileName(); + return $this->getBaseName(); } } \ No newline at end of file diff --git a/src/ImageResizer.php b/src/ImageResizer.php index 76fc136..a838a9b 100644 --- a/src/ImageResizer.php +++ b/src/ImageResizer.php @@ -272,7 +272,6 @@ public function upload($type, $input, $name, $crop = null, $rotate = null) else { throw new \TarunMangukiya\ImageResizer\Exception\InvalidInputException("Invalid Input for Image Resizer."); } - // crop the image if enabled if($crop_enabled) { $file = $this->transformImage($original_file, $type_config, $crop, $rotate); @@ -422,15 +421,15 @@ public function get($type, $size, $basename) // File Name match $pathinfo = pathinfo($basename); - $filename = $pathinfo['filename']; - $file_extension = $pathinfo['extension']; + $filename = isset($pathinfo['filename'])?$pathinfo['filename']:''; + $file_extension = isset($pathinfo['extension'])?$pathinfo['extension']:''; // Match Proper Extension $extension = $s[3]; if($extension == 'original') $extension = $file_extension; $new_path = "{$compiled_path}/{$size}/{$filename}-{$width}x{$height}.{$extension}"; } - var_dump($new_path); + if(file_exists($new_path)){ return \URL::to($new_path); }