{"record":{"id":"2e46bfc9f32c3228","repo":"BookStackApp/BookStack","slug":"errors-cannot-create-thumbs","errorCode":null,"errorMessage":"errors.cannot_create_thumbs","messagePattern":"errors\\.cannot_create_thumbs","errorType":"exception","errorClass":"ImageUploadException","httpStatus":null,"severity":"error","filePath":"app/Uploads/ImageResizer.php","lineNumber":129,"sourceCode":"\n    /**\n     * Resize the image of given data to the specified size and return the new image data.\n     * Format will remain the same as the input format, unless specified.\n     *\n     * @throws ImageUploadException\n     */\n    public function resizeImageData(\n        string $imageData,\n        ?int $width,\n        ?int $height,\n        bool $keepRatio,\n        ?string $format = null,\n    ): string {\n        try {\n            $thumb = $this->interventionFromImageData($imageData, $format);\n        } catch (Exception $e) {\n            Log::error('Failed to resize image with error:' . $e->getMessage());\n            throw new ImageUploadException(trans('errors.cannot_create_thumbs'));\n        }\n\n        $this->orientImageToOriginalExif($thumb, $imageData);\n\n        if ($keepRatio) {\n            $thumb->scaleDown($width, $height);\n        } else {\n            $thumb->cover($width, $height);\n        }\n\n        $encoder = match ($format) {\n            'png' => new PngEncoder(),\n            default => new AutoEncoder(),\n        };\n\n        $thumbData = (string) $thumb->encode($encoder);\n\n        // Use original image data if we're keeping the ratio","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/BookStackApp/BookStack/blob/18f8469a1c72f8cc8497e9372635e6dea5028071/app/Uploads/ImageResizer.php#L111-L147","documentation":"ImageUploadException with 'errors.cannot_create_thumbs' is thrown by ImageResizer::resizeImageData when interventionFromImageData() throws — meaning the image library (Intervention/GD/Imagick) could not decode or process the supplied image data. It indicates the source data is not a valid/readable image for thumbnail generation.","triggerScenarios":"Calling resizeImageData() (e.g. via resizeToThumbnailUrl) with corrupt, truncated, or zero-byte image data; an unsupported format; data whose format doesn't match the requested $format; or missing/failed PHP GD/Imagick extension.","commonSituations":"Non-image or corrupt file uploaded and thumbnails requested; PHP GD extension not installed/enabled on the server (php-gd package missing); memory_limit too low for large images causing decode failure; SVG or HEIC files unsupported by GD.","solutions":["Inspect the Laravel log for 'Failed to resize image with error: ...' to get the underlying decode failure","Install/enable a working image driver: apt install php-gd (or php-imagick) and restart PHP-FPM, then php -m | grep -i -E 'gd|imagick'","Verify the source file is a valid image (php -r 'var_dump(getimagesize(\"file\"));') and re-upload if corrupt","Raise PHP memory_limit if large images fail to decode"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before requesting a thumbnail\n$info = @getimagesizefromstring($imageData);\nif ($info === false) {\n    throw new \\InvalidArgumentException('Data is not a decodable image');\n}\nif (!extension_loaded('gd') && !extension_loaded('imagick')) {\n    throw new \\RuntimeException('No PHP image driver available');\n}","typeGuard":null,"tryCatchPattern":"try {\n    $thumbUrl = $imageResizer->resizeToThumbnailUrl($image);\n} catch (ImageUploadException $e) {\n    Log::warning('Thumbnail generation failed: ' . $e->getMessage());\n    $thumbUrl = $image->url; // fall back to original image\n}","preventionTips":["Install/enable php-gd or php-imagick and verify with php -m","Validate uploaded files are decodable images before storing them","Raise PHP memory_limit to handle large image decodes","Reject unsupported formats (e.g. HEIC, SVG for GD) at upload time"],"tags":["php","laravel","image-processing","gd","thumbnail"],"backgroundTag":"image-decode-failed","analyzedSha":"18f8469a1c72f8cc8497e9372635e6dea5028071","analyzedAt":"2026-09-02T19:49:33.068Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-10T02:17:09.455Z"}