Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
sudo apt-get update
sudo apt-get install imagemagick
sudo apt-get install ffmpeg
sudo apt-get install libheif-plugin-libde265

- uses: actions/checkout@v3

Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.31.0] - Not released
### Added
- Added JPEG Ultra HDR / JPEG_R image preview generation. For supported JPEG
images with gain maps, the server now creates a second set of JPEG previews
with gain maps and stores them as HDR-specific preview variants.

Attachments with generated HDR previews expose `meta.hdr: true`, and clients
can request the HDR version with `GET /v4/attachments/:id/image?variant=hdr`.
The `variant=hdr` query parameter is safe to send for any image attachment: if
an HDR preview is not available, the endpoint falls back to the regular SDR
preview. HDR preview responses include `variant: "hdr"`.

## [2.30.0] - 2026-04-29
### Added
Expand Down
14 changes: 13 additions & 1 deletion app/controllers/api/v1/AttachmentsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ export default class AttachmentsController {
throw new ValidationException('Invalid format value');
}

if ('variant' in query && query.variant !== 'hdr') {
throw new ValidationException('Invalid variant value');
}

const width = 'width' in query ? Number.parseInt(query.width, 10) : undefined;
const height = 'height' in query ? Number.parseInt(query.height, 10) : undefined;

Expand All @@ -206,6 +210,7 @@ export default class AttachmentsController {

const asRedirect = 'redirect' in query;
const withDownload = 'download' in query;
const preferHdr = query.variant === 'hdr';

const attachment = await dbAdapter.getAttachmentById(attId);

Expand Down Expand Up @@ -235,7 +240,8 @@ export default class AttachmentsController {
} else {
// Visual types, 'image' and 'video'

const previews = attachment.previews[type];
const useHdrPreview = type === 'image' && preferHdr && attachment.previews.imageHDR;
const previews = useHdrPreview ? attachment.previews.imageHDR : attachment.previews[type];
const {
variant,
width: resWidth,
Expand All @@ -248,11 +254,17 @@ export default class AttachmentsController {
response.width = prv.w;
response.height = prv.h;

if (useHdrPreview) {
response.variant = 'hdr';
}

// With imgproxy, we can resize images (except some types) and change
// their format
if (
useImgProxy &&
type === 'image' &&
// imgproxy doesn't support HDR images
!useHdrPreview &&
// We don't need to resize SVGs
attachment.fileExtension !== 'svg' &&
// We should not resize (probably) animated legacy GIFs
Expand Down
12 changes: 9 additions & 3 deletions app/serializers/v2/attachment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,23 @@ function serializeAttachmentV2(att: Attachment): SerializedAttachmentV2 {
function serializeAttachmentV4(att: Attachment): SerializedAttachmentV4 {
const maxVar = att.maxSizedVariant('image');
const maxPrv = att.previews.image?.[maxVar ?? '-'];
const meta: MediaMetaData = {
...att.meta,
...(att.previews.imageHDR ? { hdr: true } : {}),
};

const isMetaEmpty = Object.keys(att.meta).length === 0;
const isMetaEmpty = Object.keys(meta).length === 0;
const isPreviewSizesDifferent = maxPrv && (maxPrv.w !== att.width || maxPrv.h !== att.height);

return {
id: att.id,
mediaType: att.mediaType,
fileName: att.fileName,
fileSize: att.fileSize,
previewTypes: Object.keys(att.previews).sort() as (keyof MediaPreviews)[],
meta: isMetaEmpty ? undefined : att.meta,
previewTypes: Object.keys(att.previews)
.filter((type) => type !== 'imageHDR')
.sort() as (keyof MediaPreviews)[],
meta: isMetaEmpty ? undefined : meta,

width: att.width ?? undefined,
height: att.height ?? undefined,
Expand Down
Loading
Loading