← All changes
|
vendor/rosell-dk/webp-convert/src/Convert/Converters/Gd.php
+21
-5
3.2.21
→
4.7.0
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 |
| @@ -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 | /** |
| @@ -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 | } |