PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / trunk
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance vtrunk
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
← All changes | vendor/rosell-dk/webp-convert/src/Convert/Converters/Gd.php +23 -7 3.2.3 → trunk View file →
@@ -159,12 +159,12 @@
159 159 }
160 160 }
161 161 }
162 162 if ($success) {
163 - imagedestroy($image);
163 + $this->destroyImage($image);
164 164 $image = $dst;
165 165 } else {
166 - imagedestroy($dst);
166 + $this->destroyImage($dst);
167 167 }
168 168 return $success;
169 169 } else {
170 170 // The necessary methods for converting color palette are not avalaible
@@ -240,9 +240,9 @@
240 240 $mustMakeTrueColor = false;
241 241 if (function_exists('imageistruecolor')) {
242 242 if (imageistruecolor($image)) {
243 243 $this->logLn('image is true color');
244 - return true;
244 + $whatIsItNow = true;
245 245 } else {
246 246 $this->logLn('image is not true color');
247 247 $mustMakeTrueColor = true;
248 248 $whatIsItNow = false;
@@ -320,11 +320,11 @@
320 320 * @return void
321 321 */
322 322 protected function destroyAndRemove($image)
323 323 {
324 - imagedestroy($image);
324 + $this->destroyImage($image);
325 325 if (file_exists($this->destination)) {
326 - unlink($this->destination);
326 + @unlink($this->destination);
327 327 }
328 328 }
329 329
330 330 /**
@@ -353,9 +353,9 @@
353 353 // I'm not certain that the error handler takes care of Throwable errors.
354 354 // and - sorry - was to lazy to find out right now. So for now: better safe than sorry. #320
355 355 $error = null;
356 356 $success = false;
357 -
357 +
358 358 try {
359 359 // Beware: This call can throw FATAL on windows (cannot be catched)
360 360 // This for example happens on palette images
361 361 $success = imagewebp($image, null, $q);
@@ -530,7 +530,23 @@
530 530 // Try to convert it to webp
531 531 $this->tryConverting($image);
532 532
533 533 // End of story
534 - imagedestroy($image);
534 + $this->destroyImage($image);
535 + }
536 +
537 + /**
538 + * Safely destroy GD image resource.
539 + *
540 + * imagedestroy() has no effect since PHP 8.0 and is deprecated in PHP 8.5.
541 + * This wrapper avoids deprecation warnings while keeping backward compatibility.
542 + *
543 + * @param resource|\GdImage|null $image
544 + * @return void
545 + */
546 + private function destroyImage($image)
547 + {
548 + if (PHP_VERSION_ID < 80000 && is_resource($image)) {
549 + imagedestroy($image);
550 + }
535 551 }
536 552 }