From 1baf7ae2ca91c5ae1cc3183d908a5b1a511895a1 Mon Sep 17 00:00:00 2001 From: "DESKTOP-H825VC6\\geckon01" Date: Tue, 17 Oct 2023 02:14:37 +0300 Subject: [PATCH] Small code style improvements --- composer.json | 2 +- src/SimpleImageCompressor.php | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 11813e2..c59850d 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "geckon01/simple-image-compressor", "description": "SimpleImageCompressor is a tiny simple PHP image compressor lib which allows you to compress any image easily on the fly", - "version": "0.3.10", + "version": "0.3.10.17", "keywords": [ "php", "images", diff --git a/src/SimpleImageCompressor.php b/src/SimpleImageCompressor.php index b309b98..2ae1b45 100644 --- a/src/SimpleImageCompressor.php +++ b/src/SimpleImageCompressor.php @@ -87,9 +87,8 @@ class SimpleImageCompressor private function loadImageType() { $this->imageType = "image"; - if($this->exifLoaded) - { - switch (exif_imagetype($this->imageResourceUrl)) + if($this->exifLoaded) { + switch (exif_imagetype($this->imageResourceUrl)) { case IMAGETYPE_GIF: $this->imageType = 'image/gif'; @@ -115,14 +114,16 @@ class SimpleImageCompressor return; } - //Fallback to bytes recognition + // Fallback to bytes recognition trigger_error("simple-image-compressor: Exif extension not found. Image MIME type recognition may be inaccurate."); if (substr($this->imageData, 0, 2) === "\xFF\xD8") { $this->imageType = 'image/jpeg'; - } else if (substr($this->imageData, 0, 3) === "\x89\x50\x4E") { + } + if (substr($this->imageData, 0, 3) === "\x89\x50\x4E") { $this->imageType = 'image/png'; - } else if (substr($this->imageData, 0, 4) === "\x47\x49\x46\x38") { + } + if (substr($this->imageData, 0, 4) === "\x47\x49\x46\x38") { $this->imageType = 'image/gif'; } }