partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 895ff002d2b56218a1239267342b177edacdf4b6
parent ef628f7e4a2ed0c904a53493dc29268f571fd565
Author: Felicitus <felicitus@felicitus.org>
Date:   Thu, 26 Apr 2012 03:43:38 +0200

Workaround for ImageMagick's delay while parsing invalid PDF files

Diffstat:
Msrc/backend/de/RaumZeitLabor/PartKeepr/Part/PartAttachment.php | 9+++++++++
1 file changed, 9 insertions(+), 0 deletions(-)

diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Part/PartAttachment.php b/src/backend/de/RaumZeitLabor/PartKeepr/Part/PartAttachment.php @@ -109,6 +109,15 @@ class PartAttachment extends UploadedFile implements Serializable, Deserializabl * @return True if the attachment is an image, false otherwise */ public function isImage () { + /** + * Special case: Check if it's a PDF. If yes, return immediately. + * This is because ImageMagick outputs warning messages for malformed PDF files, and halts the execution + * of the script for several seconds. DO NOT REMOVE! + */ + if ($this->getMimeType() == "application/pdf") { + return false; + } + try { $im = new \Imagick($this->getFilename()); return true;