[PR #7513] feat(server): optimize person thumbnail generation #11665

Closed
opened 2026-02-05 14:43:44 +03:00 by OVERLORD · 0 comments
Owner

Original Pull Request: https://github.com/immich-app/immich/pull/7513

State: closed
Merged: Yes


Description

Person thumbnails are currently generated by cropping to a buffer and passing this buffer to sharp to resize. This is inefficient:

  1. It ends up generating two thumbnails instead of one (the buffer is implicitly a new JPEG file)
  2. libvips is optimized for longer image processing pipelines, so separating the workload here is worse for performance
  3. It lowers quality as person thumbnails are compressed at least three times: once due to the use of the compressed preview image, a second time with the buffer, and a third time with the resize

This PR combines cropping and resizing to the same pipeline for better performance and less compressed thumbnails. Additionally, it uses the original image to generate the thumbnail to further reduce compression artifacts, scaling the bounding box dimensions as needed.

How Has This Been Tested?

I ran facial recognition on all assets and confirmed the person thumbnails are accurately cropped and look normal.

Before:

person-thumbnail-before

After:

person-thumbnail-after

**Original Pull Request:** https://github.com/immich-app/immich/pull/7513 **State:** closed **Merged:** Yes --- ## Description Person thumbnails are currently generated by cropping to a buffer and passing this buffer to sharp to resize. This is inefficient: 1. It ends up generating two thumbnails instead of one (the buffer is implicitly a new JPEG file) 2. libvips is optimized for longer image processing pipelines, so separating the workload here is worse for performance 3. It lowers quality as person thumbnails are compressed at least three times: once due to the use of the compressed preview image, a second time with the buffer, and a third time with the resize This PR combines cropping and resizing to the same pipeline for better performance and less compressed thumbnails. Additionally, it uses the original image to generate the thumbnail to further reduce compression artifacts, scaling the bounding box dimensions as needed. ### How Has This Been Tested? I ran facial recognition on all assets and confirmed the person thumbnails are accurately cropped and look normal. Before: ![person-thumbnail-before](https://github.com/immich-app/immich/assets/101130780/2e9f4bc3-89f2-499c-aeea-bfe2887b5937) After: ![person-thumbnail-after](https://github.com/immich-app/immich/assets/101130780/3d536801-5b12-4038-abb2-9641a31c5fd8)
OVERLORD added the pull-request label 2026-02-05 14:43:44 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: immich-app/immich#11665