From cdc855bb65ae6a299bde354d543d4c665d6cde49 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Wed, 28 Jun 2023 23:09:55 +0200 Subject: [PATCH] Add check if sample image is jpeg. Closes #1253 --- .../processing/post/ProcessAdditional.php | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/Blacklight/processing/post/ProcessAdditional.php b/Blacklight/processing/post/ProcessAdditional.php index 7b8df5c30..db49c6dd6 100755 --- a/Blacklight/processing/post/ProcessAdditional.php +++ b/Blacklight/processing/post/ProcessAdditional.php @@ -1360,27 +1360,23 @@ class ProcessAdditional // Try to create a file with it. File::put($this->tmpPath.'samplepicture.jpg', $jpgBinary); - // Try to resize and move it. - $this->_foundJPGSample = ( - $this->_releaseImage->saveImage( - $this->_release->guid.'_thumb', - $this->tmpPath.'samplepicture.jpg', - $this->_releaseImage->jpgSavePath, - 650, - 650 - ) === 1 - ); + // Check if image exif data is jpeg + if (exif_imagetype($this->tmpPath.'samplepicture.jpg') === IMAGETYPE_JPEG) { + // Try to resize and move it. + $this->_foundJPGSample = ($this->_releaseImage->saveImage($this->_release->guid.'_thumb', + $this->tmpPath.'samplepicture.jpg', $this->_releaseImage->jpgSavePath, 650, 650) === 1); - if ($this->_foundJPGSample) { - // Update the DB to say we got it. - Release::query()->where('id', $this->_release->id)->update(['jpgstatus' => 1]); + if ($this->_foundJPGSample) { + // Update the DB to say we got it. + Release::query()->where('id', $this->_release->id)->update(['jpgstatus' => 1]); - if ($this->_echoCLI) { - $this->_echo('j', 'primaryOver'); + if ($this->_echoCLI) { + $this->_echo('j', 'primaryOver'); + } } - } - File::delete($this->tmpPath.'samplepicture.jpg'); + File::delete($this->tmpPath.'samplepicture.jpg'); + } } elseif ($this->_echoCLI) { $this->_echo('f', 'warningOver'); }