[JobService] Unable to run job handler (thumbnailGeneration/generate-preview): Error: Processed image is too large for the WebP format #3136

Closed
opened 2026-02-05 07:50:27 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @loveyu on GitHub (May 15, 2024).

The bug

I encountered an issue while trying to generate a thumbnail for an image with a very large aspect ratio. The image in question is 790x36861 pixels. You can view it here: Image Link.

When attempting to generate the thumbnail, the process fails, and the following error is logged on the server:

[JobService] Unable to run job handler (thumbnailGeneration/generate-preview): Error: Processed image is too large for the WebP format

The OS that Immich Server is running on

Debian 12

Version of Immich Server

v1.105.1

Version of Immich Mobile App

v1.105.1

Platform with the issue

  • Server
  • Web
  • Mobile

Your docker-compose.yml content

#
# WARNING: Make sure to use the docker-compose.yml of the current release:
#
# https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
#
# The compose file on main may not be compatible with the latest release.
#

name: immich

services:
  immich-server:
    container_name: immich_server
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    command: ['start.sh', 'immich']
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    ports:
      - 2283:3001
    depends_on:
      - redis
      - database
    restart: always

  immich-microservices:
    container_name: immich_microservices
    image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
    # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/hardware-transcoding
    #   file: hwaccel.transcoding.yml
    #   service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
    command: ['start.sh', 'microservices']
    volumes:
      - ${UPLOAD_LOCATION}:/usr/src/app/upload
      - /etc/localtime:/etc/localtime:ro
    env_file:
      - .env
    depends_on:
      - redis
      - database
    restart: always

  immich-machine-learning:
    container_name: immich_machine_learning
    # For hardware acceleration, add one of -[armnn, cuda, openvino] to the image tag.
    # Example tag: ${IMMICH_VERSION:-release}-cuda
    image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
    # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration
    #   file: hwaccel.ml.yml
    #   service: cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference - use the `-wsl` version for WSL2 where applicable
    volumes:
      - model-cache:/cache
    env_file:
      - .env
    restart: always

  redis:
    container_name: immich_redis
    image: registry.hub.docker.com/library/redis:6.2-alpine@sha256:84882e87b54734154586e5f8abd4dce69fe7311315e2fc6d67c29614c8de2672
    restart: always

  database:
    container_name: immich_postgres
    image: registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
    environment:
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_USER: ${DB_USERNAME}
      POSTGRES_DB: ${DB_DATABASE_NAME}
      POSTGRES_INITDB_ARGS: '--data-checksums'
    volumes:
      - ${DB_DATA_LOCATION}:/var/lib/postgresql/data
    restart: always
    command: ["postgres", "-c" ,"shared_preload_libraries=vectors.so", "-c", 'search_path="$$user", public, vectors', "-c", "logging_collector=on", "-c", "max_wal_size=2GB", "-c", "shared_buffers=512MB", "-c", "wal_compression=on"]

volumes:
  model-cache:

Your .env content

# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables

# The location where your uploaded files are stored
UPLOAD_LOCATION=./library
# The location where your database files are stored
DB_DATA_LOCATION=./postgres

# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release

# Connection secret for postgres. You should change it to a random password
DB_PASSWORD=postgres

# The values below this line do not need to be changed
###################################################################################
DB_USERNAME=postgres
DB_DATABASE_NAME=immich

Reproduction steps

1. Download image https://imgur.com/a/B661EBu
2. Upload an image with a large aspect ratio (e.g., 790x36861).
3. Attempt to generate a thumbnail.
4. Observe the error in the server logs.

Relevant log output

[Nest] 7  - 05/15/2024, 12:32:55 PM   ERROR [ImmichMicroservices] [JobService] Unable to run job handler (thumbnailGeneration/generate-preview): Error: Processed image is too large for the WebP format
[Nest] 7  - 05/15/2024, 12:32:55 PM   ERROR [ImmichMicroservices] [JobService] Error: Processed image is too large for the WebP format
    at Sharp.toFile (/usr/src/app/node_modules/sharp/lib/output.js:89:19)
    at MediaRepository.generateThumbnail (/usr/src/app/dist/repositories/media.repository.js:69:14)
    at MediaService.generateThumbnail (/usr/src/app/dist/services/media.service.js:158:48)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async MediaService.handleGeneratePreview (/usr/src/app/dist/services/media.service.js:135:29)
    at async /usr/src/app/dist/services/job.service.js:145:36
    at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28)
    at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)

Additional information

The issue seems to be related to the WebP format's limitations on image dimensions.

Exif info:

{
    "ExifToolVersion": 12.64,
    "FileName": "IMG_3054.JPG",
    "Directory": "alistyou/2019/2019-12-16",
    "FileSize": "11 MB",
    "FileModifyDate": "2023:04:10 00:25:11+08:00",
    "FileAccessDate": "2024:05:15 12:29:54+08:00",
    "FileInodeChangeDate": "2023:04:10 00:25:11+08:00",
    "FilePermissions": "-rwxr-xr-x",
    "FileType": "JPEG",
    "FileTypeExtension": "jpg",
    "MIMEType": "image/jpeg",
    "ExifByteOrder": "Big-endian (Motorola, MM)",
    "Orientation": "Horizontal (normal)",
    "XResolution": 72,
    "YResolution": 72,
    "ResolutionUnit": "inches",
    "Software": "Adobe Photoshop CC (Windows)",
    "ModifyDate": "2020:01:31 13:07:00",
    "YCbCrPositioning": "Centered",
    "ExifVersion": "0221",
    "CreateDate": "2019:12:16 22:36:03",
    "ComponentsConfiguration": "Y, Cb, Cr, -",
    "FlashpixVersion": "0100",
    "ColorSpace": "Uncalibrated",
    "ExifImageWidth": 790,
    "ExifImageHeight": 36861,
    "SceneCaptureType": "Standard",
    "Compression": "JPEG (old-style)",
    "ThumbnailOffset": 404,
    "ThumbnailLength": 1851,
    "XMPToolkit": "Adobe XMP Core 5.6-c142 79.160924, 2017/07/13-01:06:39        ",
    "CreatorTool": "Adobe Photoshop CC (Windows)",
    "MetadataDate": "2020:01:31 13:07+08:00",
    "ColorMode": "RGB",
    "Format": "image/jpeg",
    "CodedCharacterSet": "UTF8",
    "ApplicationRecordVersion": 0,
    "DisplayedUnitsX": "inches",
    "DisplayedUnitsY": "inches",
    "PrintStyle": "Centered",
    "PrintPosition": "0 0",
    "PrintScale": 1,
    "GlobalAngle": 90,
    "GlobalAltitude": 30,
    "URL_List": [],
    "SlicesGroupName": "\u0003",
    "PixelAspectRatio": 1,
    "PhotoshopThumbnail": "(Binary data 1060 bytes, use -b option to extract)",
    "HasRealMergedData": "Yes",
    "WriterName": "Adobe Photoshop",
    "ReaderName": "Adobe Photoshop CC",
    "PhotoshopQuality": 12,
    "PhotoshopFormat": "Standard",
    "DigitalCreationDate": "2019:12:16",
    "DigitalCreationTime": "22:36:03+08:00",
    "IPTCDigest": "f454c308b7d996c03d33e2080be10e7d",
    "Warning": "IPTCDigest is not current. XMP may be out of sync",
    "DCTEncodeVersion": 100,
    "APP14Flags0": [
        14
    ],
    "APP14Flags1": "(none)",
    "ColorTransform": "YCbCr",
    "ImageWidth": 790,
    "ImageHeight": 36861,
    "EncodingProcess": "Baseline DCT, Huffman coding",
    "BitsPerSample": 8,
    "ColorComponents": 3,
    "YCbCrSubSampling": "YCbCr4:4:4 (1 1)",
    "ImageSize": "790x36861",
    "Megapixels": 29.1,
    "ThumbnailImage": "(Binary data 1851 bytes, use -b option to extract)",
    "DigitalCreationDateTime": "2019:12:16 22:36:03+08:00"
}
Originally created by @loveyu on GitHub (May 15, 2024). ### The bug I encountered an issue while trying to generate a thumbnail for an image with a very large aspect ratio. The image in question is 790x36861 pixels. You can view it here: [Image Link](https://imgur.com/a/B661EBu). When attempting to generate the thumbnail, the process fails, and the following error is logged on the server: ``` [JobService] Unable to run job handler (thumbnailGeneration/generate-preview): Error: Processed image is too large for the WebP format ``` ### The OS that Immich Server is running on Debian 12 ### Version of Immich Server v1.105.1 ### Version of Immich Mobile App v1.105.1 ### Platform with the issue - [X] Server - [ ] Web - [ ] Mobile ### Your docker-compose.yml content ```YAML # # WARNING: Make sure to use the docker-compose.yml of the current release: # # https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml # # The compose file on main may not be compatible with the latest release. # name: immich services: immich-server: container_name: immich_server image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} command: ['start.sh', 'immich'] volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload - /etc/localtime:/etc/localtime:ro env_file: - .env ports: - 2283:3001 depends_on: - redis - database restart: always immich-microservices: container_name: immich_microservices image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release} # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/hardware-transcoding # file: hwaccel.transcoding.yml # service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding command: ['start.sh', 'microservices'] volumes: - ${UPLOAD_LOCATION}:/usr/src/app/upload - /etc/localtime:/etc/localtime:ro env_file: - .env depends_on: - redis - database restart: always immich-machine-learning: container_name: immich_machine_learning # For hardware acceleration, add one of -[armnn, cuda, openvino] to the image tag. # Example tag: ${IMMICH_VERSION:-release}-cuda image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release} # extends: # uncomment this section for hardware acceleration - see https://immich.app/docs/features/ml-hardware-acceleration # file: hwaccel.ml.yml # service: cpu # set to one of [armnn, cuda, openvino, openvino-wsl] for accelerated inference - use the `-wsl` version for WSL2 where applicable volumes: - model-cache:/cache env_file: - .env restart: always redis: container_name: immich_redis image: registry.hub.docker.com/library/redis:6.2-alpine@sha256:84882e87b54734154586e5f8abd4dce69fe7311315e2fc6d67c29614c8de2672 restart: always database: container_name: immich_postgres image: registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0 environment: POSTGRES_PASSWORD: ${DB_PASSWORD} POSTGRES_USER: ${DB_USERNAME} POSTGRES_DB: ${DB_DATABASE_NAME} POSTGRES_INITDB_ARGS: '--data-checksums' volumes: - ${DB_DATA_LOCATION}:/var/lib/postgresql/data restart: always command: ["postgres", "-c" ,"shared_preload_libraries=vectors.so", "-c", 'search_path="$$user", public, vectors', "-c", "logging_collector=on", "-c", "max_wal_size=2GB", "-c", "shared_buffers=512MB", "-c", "wal_compression=on"] volumes: model-cache: ``` ### Your .env content ```Shell # You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables # The location where your uploaded files are stored UPLOAD_LOCATION=./library # The location where your database files are stored DB_DATA_LOCATION=./postgres # The Immich version to use. You can pin this to a specific version like "v1.71.0" IMMICH_VERSION=release # Connection secret for postgres. You should change it to a random password DB_PASSWORD=postgres # The values below this line do not need to be changed ################################################################################### DB_USERNAME=postgres DB_DATABASE_NAME=immich ``` ### Reproduction steps ```bash 1. Download image https://imgur.com/a/B661EBu 2. Upload an image with a large aspect ratio (e.g., 790x36861). 3. Attempt to generate a thumbnail. 4. Observe the error in the server logs. ``` ### Relevant log output ```shell [Nest] 7 - 05/15/2024, 12:32:55 PM ERROR [ImmichMicroservices] [JobService] Unable to run job handler (thumbnailGeneration/generate-preview): Error: Processed image is too large for the WebP format [Nest] 7 - 05/15/2024, 12:32:55 PM ERROR [ImmichMicroservices] [JobService] Error: Processed image is too large for the WebP format at Sharp.toFile (/usr/src/app/node_modules/sharp/lib/output.js:89:19) at MediaRepository.generateThumbnail (/usr/src/app/dist/repositories/media.repository.js:69:14) at MediaService.generateThumbnail (/usr/src/app/dist/services/media.service.js:158:48) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async MediaService.handleGeneratePreview (/usr/src/app/dist/services/media.service.js:135:29) at async /usr/src/app/dist/services/job.service.js:145:36 at async Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:28) at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24) ``` ### Additional information The issue seems to be related to the WebP format's limitations on image dimensions. Exif info: ``` { "ExifToolVersion": 12.64, "FileName": "IMG_3054.JPG", "Directory": "alistyou/2019/2019-12-16", "FileSize": "11 MB", "FileModifyDate": "2023:04:10 00:25:11+08:00", "FileAccessDate": "2024:05:15 12:29:54+08:00", "FileInodeChangeDate": "2023:04:10 00:25:11+08:00", "FilePermissions": "-rwxr-xr-x", "FileType": "JPEG", "FileTypeExtension": "jpg", "MIMEType": "image/jpeg", "ExifByteOrder": "Big-endian (Motorola, MM)", "Orientation": "Horizontal (normal)", "XResolution": 72, "YResolution": 72, "ResolutionUnit": "inches", "Software": "Adobe Photoshop CC (Windows)", "ModifyDate": "2020:01:31 13:07:00", "YCbCrPositioning": "Centered", "ExifVersion": "0221", "CreateDate": "2019:12:16 22:36:03", "ComponentsConfiguration": "Y, Cb, Cr, -", "FlashpixVersion": "0100", "ColorSpace": "Uncalibrated", "ExifImageWidth": 790, "ExifImageHeight": 36861, "SceneCaptureType": "Standard", "Compression": "JPEG (old-style)", "ThumbnailOffset": 404, "ThumbnailLength": 1851, "XMPToolkit": "Adobe XMP Core 5.6-c142 79.160924, 2017/07/13-01:06:39 ", "CreatorTool": "Adobe Photoshop CC (Windows)", "MetadataDate": "2020:01:31 13:07+08:00", "ColorMode": "RGB", "Format": "image/jpeg", "CodedCharacterSet": "UTF8", "ApplicationRecordVersion": 0, "DisplayedUnitsX": "inches", "DisplayedUnitsY": "inches", "PrintStyle": "Centered", "PrintPosition": "0 0", "PrintScale": 1, "GlobalAngle": 90, "GlobalAltitude": 30, "URL_List": [], "SlicesGroupName": "\u0003", "PixelAspectRatio": 1, "PhotoshopThumbnail": "(Binary data 1060 bytes, use -b option to extract)", "HasRealMergedData": "Yes", "WriterName": "Adobe Photoshop", "ReaderName": "Adobe Photoshop CC", "PhotoshopQuality": 12, "PhotoshopFormat": "Standard", "DigitalCreationDate": "2019:12:16", "DigitalCreationTime": "22:36:03+08:00", "IPTCDigest": "f454c308b7d996c03d33e2080be10e7d", "Warning": "IPTCDigest is not current. XMP may be out of sync", "DCTEncodeVersion": 100, "APP14Flags0": [ 14 ], "APP14Flags1": "(none)", "ColorTransform": "YCbCr", "ImageWidth": 790, "ImageHeight": 36861, "EncodingProcess": "Baseline DCT, Huffman coding", "BitsPerSample": 8, "ColorComponents": 3, "YCbCrSubSampling": "YCbCr4:4:4 (1 1)", "ImageSize": "790x36861", "Megapixels": 29.1, "ThumbnailImage": "(Binary data 1851 bytes, use -b option to extract)", "DigitalCreationDateTime": "2019:12:16 22:36:03+08:00" } ```
Author
Owner

@alextran1502 commented on GitHub (May 15, 2024):

Duplicated of #4017

@alextran1502 commented on GitHub (May 15, 2024): Duplicated of #4017
Author
Owner

@mertalev commented on GitHub (May 15, 2024):

This is different from the other issue because this isn't a limit sharp sets, but a limitation of the WebP format itself. You can change the preview format to JPEG, refresh thumbnails for this image and change it back. Or if there are more images like this, keep it set to JPEG.

@mertalev commented on GitHub (May 15, 2024): This is different from the other issue because this isn't a limit sharp sets, but a limitation of the WebP format itself. You can change the preview format to JPEG, refresh thumbnails for this image and change it back. Or if there are more images like this, keep it set to JPEG.
Author
Owner

@loveyu commented on GitHub (May 15, 2024):

This issue is caused by WebP's limitations, but the real problem is that the thumbnail generator doesn't restrict the max dimensions.
The image has an aspect ratio of 1:46, which would look odd even if the thumbnail were created successfully.
I suggest limiting the aspect ratio to 1:10 at most. If an image exceeds this, just crop and scale the center part.
A similar approach could work for #4033 , There are also techniques to solve issues when cropping with sharp.

@loveyu commented on GitHub (May 15, 2024): This issue is caused by WebP's limitations, but the real problem is that the thumbnail generator doesn't restrict the max dimensions. The image has an aspect ratio of 1:46, which would look odd even if the thumbnail were created successfully. I suggest limiting the aspect ratio to 1:10 at most. If an image exceeds this, just crop and scale the center part. A similar approach could work for #4033 , There are also techniques to solve issues when cropping with **sharp**.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#3136