BookStackApp/BookStack · error · ImageUploadException

errors.cannot_create_thumbs

Error message

errors.cannot_create_thumbs

What it means

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.

Source

Thrown at app/Uploads/ImageResizer.php:129

    /**
     * Resize the image of given data to the specified size and return the new image data.
     * Format will remain the same as the input format, unless specified.
     *
     * @throws ImageUploadException
     */
    public function resizeImageData(
        string $imageData,
        ?int $width,
        ?int $height,
        bool $keepRatio,
        ?string $format = null,
    ): string {
        try {
            $thumb = $this->interventionFromImageData($imageData, $format);
        } catch (Exception $e) {
            Log::error('Failed to resize image with error:' . $e->getMessage());
            throw new ImageUploadException(trans('errors.cannot_create_thumbs'));
        }

        $this->orientImageToOriginalExif($thumb, $imageData);

        if ($keepRatio) {
            $thumb->scaleDown($width, $height);
        } else {
            $thumb->cover($width, $height);
        }

        $encoder = match ($format) {
            'png' => new PngEncoder(),
            default => new AutoEncoder(),
        };

        $thumbData = (string) $thumb->encode($encoder);

        // Use original image data if we're keeping the ratio

View on GitHub (pinned to 18f8469a1c)

Solutions

  1. Inspect the Laravel log for 'Failed to resize image with error: ...' to get the underlying decode failure
  2. 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'
  3. Verify the source file is a valid image (php -r 'var_dump(getimagesize("file"));') and re-upload if corrupt
  4. Raise PHP memory_limit if large images fail to decode
Defensive patterns

Strategy: try-catch

Validate before calling

// before requesting a thumbnail
$info = @getimagesizefromstring($imageData);
if ($info === false) {
    throw new \InvalidArgumentException('Data is not a decodable image');
}
if (!extension_loaded('gd') && !extension_loaded('imagick')) {
    throw new \RuntimeException('No PHP image driver available');
}

Try / catch

try {
    $thumbUrl = $imageResizer->resizeToThumbnailUrl($image);
} catch (ImageUploadException $e) {
    Log::warning('Thumbnail generation failed: ' . $e->getMessage());
    $thumbUrl = $image->url; // fall back to original image
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of BookStackApp/BookStack@18f8469a1c (2026-09-02). Data as JSON: /api/errors/2e46bfc9f32c3228. Report an issue: GitHub.