@@ -55,7 +55,7 @@ public function loadGalleryThumbnailsForImage(Image $image, bool $shouldCreate):
5555
5656 /**
5757 * Get the thumbnail for an image.
58- * If $keepRatio is true only the width will be used.
58+ * If $keepRatio is true, only the width will be used.
5959 * Checks the cache then storage to avoid creating / accessing the filesystem on every check.
6060 *
6161 * @throws Exception
@@ -84,7 +84,7 @@ public function resizeToThumbnailUrl(
8484 return $ this ->storage ->getPublicUrl ($ cachedThumbPath );
8585 }
8686
87- // If thumbnail has already been generated, serve that and cache path
87+ // If a thumbnail has already been generated, serve that and cache path
8888 $ disk = $ this ->storage ->getDisk ($ image ->type );
8989 if (!$ shouldCreate && $ disk ->exists ($ thumbFilePath )) {
9090 Cache::put ($ thumbCacheKey , $ thumbFilePath , static ::THUMBNAIL_CACHE_TIME );
@@ -110,7 +110,7 @@ public function resizeToThumbnailUrl(
110110 }
111111
112112 /**
113- * Resize the image of given data to the specified size, and return the new image data.
113+ * Resize the image of given data to the specified size and return the new image data.
114114 * Format will remain the same as the input format, unless specified.
115115 *
116116 * @throws ImageUploadException
@@ -125,6 +125,7 @@ public function resizeImageData(
125125 try {
126126 $ thumb = $ this ->interventionFromImageData ($ imageData , $ format );
127127 } catch (Exception $ e ) {
128+ Log::error ('Failed to resize image with error: ' . $ e ->getMessage ());
128129 throw new ImageUploadException (trans ('errors.cannot_create_thumbs ' ));
129130 }
130131
@@ -154,17 +155,21 @@ public function resizeImageData(
154155
155156 /**
156157 * Create an intervention image instance from the given image data.
157- * Performs some manual library usage to ensure image is specifically loaded
158+ * Performs some manual library usage to ensure the image is specifically loaded
158159 * from given binary data instead of data being misinterpreted.
159160 */
160161 protected function interventionFromImageData (string $ imageData , ?string $ fileType ): InterventionImage
161162 {
163+ if (!extension_loaded ('gd ' )) {
164+ throw new ImageUploadException ('The PHP "gd" extension is required to resize images, but is missing. ' );
165+ }
166+
162167 $ manager = new ImageManager (
163168 new Driver (),
164169 autoOrientation: false ,
165170 );
166171
167- // Ensure gif images are decoded natively instead of deferring to intervention GIF
172+ // Ensure GIF images are decoded natively instead of deferring to intervention GIF
168173 // handling since we don't need the added animation support.
169174 $ isGif = $ fileType === 'gif ' ;
170175 $ decoder = $ isGif ? NativeObjectDecoder::class : BinaryImageDecoder::class;
@@ -223,7 +228,7 @@ protected function orientImageToOriginalExif(InterventionImage $image, string $o
223228 }
224229
225230 /**
226- * Checks if the image is a gif . Returns true if it is, else false.
231+ * Checks if the image is a GIF . Returns true if it is, else false.
227232 */
228233 protected function isGif (Image $ image ): bool
229234 {
@@ -250,7 +255,7 @@ protected function isApngData(string &$imageData): bool
250255
251256 /**
252257 * Check if the given avif image data represents an animated image.
253- * This is based up the answer here: https://stackoverflow.com/a/79457313
258+ * This is based upon the answer here: https://stackoverflow.com/a/79457313
254259 */
255260 protected function isAnimatedAvifData (string &$ imageData ): bool
256261 {
0 commit comments