From b93c0fe8e9b93484851ead12ce61eb94dd9ad31d Mon Sep 17 00:00:00 2001 From: Bart Lagerweij Date: Thu, 11 Nov 2021 11:52:37 +0100 Subject: [PATCH] Prevent copy exception When resizing the same file and the requested size is the same as the maximum size, you will get this error: Uncaught PHP Exception SpoonDirectoryException: "The directory/file (...) couldn't be copied." at spoon/library/spoon/directory/directory.php line 124 When resizing from file1 to file2, and no resize is needed, a file copy is necessary. But when resizing from file1 to file1, and no resize is needed, the copy function should be skipped. --- spoon/thumbnail/thumbnail.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spoon/thumbnail/thumbnail.php b/spoon/thumbnail/thumbnail.php index 7bb58e6..130e8e7 100644 --- a/spoon/thumbnail/thumbnail.php +++ b/spoon/thumbnail/thumbnail.php @@ -264,6 +264,10 @@ public function parseToFile($filename, $quality = 100, $chmod = 0666) { if($currentWidth == $this->width && $currentHeight == $this->height) { + if($this->filename == $filename) + { + return true; + } return SpoonDirectory::copy($this->filename, $filename, true, true, $chmod); } }