Skip to content
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9a51ceb
Media: Add UltraHDR (ISO 21496-1) gain map support
adamsilverstein Jan 21, 2026
86f2549
UltraHDR: Switch to open-ultrahdr-wasm npm package
adamsilverstein Jan 22, 2026
536b513
UltraHDR: Replace local packages with open-ultrahdr npm package
adamsilverstein Jan 22, 2026
6ed5fca
Fix TypeScript error: Add meta property to Attachment interface
adamsilverstein Jan 22, 2026
e724e52
UltraHDR: Use probeUltraHdr, upload originals unmodified
adamsilverstein Mar 17, 2026
cae597e
Fix package-lock.json: preserve esbuild version pinning from trunk
adamsilverstein Mar 17, 2026
9ffad4b
Remove open-ultrahdr from root package.json
adamsilverstein Mar 17, 2026
1156564
UltraHDR: Skip transcoding and handle array meta
adamsilverstein Mar 18, 2026
3a78c37
Address PR feedback: tighten try/catch scope and remove unused enum
adamsilverstein Mar 26, 2026
813c371
Inline UltraHDR WASM as base64 data URL like vips
adamsilverstein Mar 26, 2026
38c96cc
Revert unrelated webpack.config.js import reordering
adamsilverstein Mar 26, 2026
bd66a87
Preserve ISO gain maps in sub-sized images
adamsilverstein Apr 6, 2026
eec2249
Fix Uint8Array to BlobPart type error in gain map decoding
adamsilverstein Apr 6, 2026
84f8ea1
Fix ArrayBufferLike to BlobPart TypeScript error in gain map decoding
adamsilverstein Apr 6, 2026
d7d1d48
Fix gain map buffer type: cast ArrayBufferLike to ArrayBuffer for Blob
adamsilverstein Apr 6, 2026
7a832b7
Merge trunk into open-ultrahdr-package
adamsilverstein Apr 13, 2026
dbd21b2
Integrate copyMemory() batch thumbnail path with UltraHDR
adamsilverstein Apr 13, 2026
1f2b4a8
Merge branch 'trunk' into open-ultrahdr-package
adamsilverstein Apr 21, 2026
a079153
Merge branch 'trunk' into open-ultrahdr-package
adamsilverstein Apr 23, 2026
086dba5
Upload Media: Bump open-ultrahdr to 0.2.0 (Apache-2.0 OR MIT)
adamsilverstein May 8, 2026
5975eec
Upload Media: Refresh package-lock for open-ultrahdr 0.2.0
adamsilverstein May 8, 2026
1830462
Vips: Add UltraHDR-aware resize via wasm-vips 0.0.17
adamsilverstein May 8, 2026
5ddd065
Upload Media: Use wasm-vips's native UltraHDR support
adamsilverstein May 8, 2026
283890e
Merge remote-tracking branch 'origin/trunk' into open-ultrahdr-package
adamsilverstein May 8, 2026
1edd5d7
Upload Media: Add UltraHDR test coverage
adamsilverstein May 9, 2026
fb03416
Update packages/vips/src/index.ts
adamsilverstein May 9, 2026
f17ac14
Vips: Simplify UltraHDR resize via libvips auto-detection
adamsilverstein May 10, 2026
0ccd44c
Vips: Fix lint errors in UltraHDR fixture generator
adamsilverstein May 10, 2026
acdb6fa
Performance: Disable libvips operation cache in media-processing spec
adamsilverstein May 10, 2026
c5e8e72
Merge branch 'trunk' into open-ultrahdr-package
adamsilverstein May 15, 2026
8cbf898
Merge remote-tracking branch 'origin/trunk' into open-ultrahdr-package
adamsilverstein May 18, 2026
8278da5
Merge remote-tracking branch 'origin/trunk' into open-ultrahdr-package
adamsilverstein May 27, 2026
fd30609
Tests: Add missing Cache.max to wasm-vips mock in ultrahdr tests
adamsilverstein May 27, 2026
b608550
Merge branch 'trunk' into open-ultrahdr-package
adamsilverstein May 27, 2026
6568944
Upload Media: clear UltraHDR tracking when an item is removed
adamsilverstein Jun 3, 2026
215ed5d
Upload Media: drop changelog note about unlanded open-ultrahdr deps
adamsilverstein Jun 3, 2026
cd0acc4
Upload Media: add tests confirming sub-size gain map preservation
adamsilverstein Jun 3, 2026
9a1a40b
create-block: revert stray import reordering in check-system-requirem…
adamsilverstein Jun 3, 2026
5500ed3
Upload Media: drop unused UltraHDR attachment meta
adamsilverstein Jun 5, 2026
73f662c
vips: round gain map crop coordinates to integers
adamsilverstein Jun 5, 2026
17179a6
Tests: move UltraHDR e2e fixture generator to bin
adamsilverstein Jun 5, 2026
d733172
Merge remote-tracking branch 'origin/trunk' into open-ultrahdr-package
adamsilverstein Jun 5, 2026
cae2214
Merge remote-tracking branch 'origin/trunk' into open-ultrahdr-package
adamsilverstein Jun 7, 2026
e847253
Merge remote-tracking branch 'origin/trunk' into open-ultrahdr-package
adamsilverstein Jun 7, 2026
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
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/upload-media/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Enhancement

- UltraHDR (ISO 21496-1 gain map) JPEGs are now detected and resized via libvips's native `uhdrload`/`uhdrsave` pipeline, so gain maps are preserved automatically through the existing resize step ([#74873](https://github.com/WordPress/gutenberg/pull/74873)).

## 0.32.0 (2026-05-27)

### Bug Fix
Expand Down
101 changes: 93 additions & 8 deletions packages/upload-media/src/store/private-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
vipsRotateImage,
vipsConvertImageFormat,
vipsHasTransparency,
vipsGetUltraHdrInfo,
terminateVipsWorker,
maybeRecycleVipsWorker,
} from './utils';
Expand Down Expand Up @@ -62,6 +63,15 @@ import type { cancelItem } from './actions';

const DEFAULT_OUTPUT_QUALITY = 0.82;

/**
* Tracks parent item IDs whose source file is an UltraHDR JPEG so that
* sub-size resize operations can route through libvips's uhdrload/uhdrsave
* to preserve the gain map. Entries are cleared in `removeItem` when the
* parent item leaves the queue, covering both successful completion and
* cancellation.
*/
const ultraHdrItems = new Set< QueueItemId >();

Comment thread
adamsilverstein marked this conversation as resolved.
Resolved
type ActionCreators = {
cancelItem: typeof cancelItem;
addItem: typeof addItem;
Expand All @@ -80,6 +90,7 @@ type ActionCreators = {
finalizeItem: typeof finalizeItem;
updateItemProgress: typeof updateItemProgress;
revokeBlobUrls: typeof revokeBlobUrls;
detectUltraHdr: typeof detectUltraHdr;
< T = Record< string, unknown > >( args: T ): void;
};

Expand Down Expand Up @@ -441,6 +452,10 @@ export function processItem( id: QueueItemId ) {
case OperationType.Finalize:
dispatch.finalizeItem( id );
break;

case OperationType.DetectUltraHdr:
dispatch.detectUltraHdr( id );
break;
}
};
}
Expand Down Expand Up @@ -502,6 +517,11 @@ export function removeItem( id: QueueItemId ) {
return;
}

// Clear any UltraHDR tracking for this item. removeItem runs on both
// successful completion and cancellation, so this prevents the set
// from growing unbounded over a long editing session.
ultraHdrItems.delete( id );

dispatch( {
type: Type.Remove,
id,
Expand Down Expand Up @@ -658,6 +678,9 @@ export async function getTranscodeImageOperation(
* Or videos need to be compressed, and then need poster generation
* before upload.
*
* UltraHDR JPEG images are detected and uploaded unmodified — they are
* already backwards compatible (SDR displays use the embedded base image).
*
* @param id Item ID.
*/
export function prepareItem( id: QueueItemId ) {
Expand All @@ -678,6 +701,11 @@ export function prepareItem( id: QueueItemId ) {
);
const isHeic = HEIC_MIME_TYPES.includes( file.type );

// Check for UltraHDR in JPEG files before other operations.
if ( file.type === 'image/jpeg' ) {
operations.push( OperationType.DetectUltraHdr );
}

// For images that can be processed by vips, upload the original and
// let generateThumbnails() handle threshold scaling as a sideload.
//
Expand Down Expand Up @@ -782,6 +810,54 @@ export function prepareItem( id: QueueItemId ) {
};
}

/**
* Detects whether a JPEG is an UltraHDR image and records the parent item
* ID so that downstream resize operations route through libvips's
* uhdrload/uhdrsave pipeline (which preserves the gain map).
*
* @param id Item ID.
*/
export function detectUltraHdr( id: QueueItemId ) {
return async ( { select, dispatch }: ThunkArgs ) => {
const item = select.getItem( id );
if ( ! item ) {
return;
}

let info;
try {
const buffer = await item.file.arrayBuffer();
info = await vipsGetUltraHdrInfo( buffer );
} catch {
// If UltraHDR detection fails, continue with regular upload.
}

if ( info ) {
ultraHdrItems.add( id );

// Mark attachment metadata with UltraHDR info. The original file
// is uploaded unmodified — UltraHDR JPEGs are already backwards
// compatible (SDR displays use the embedded base image).
const existingMeta = Array.isArray( item.attachment?.meta )
? {}
: item.attachment?.meta || {};
dispatch.finishOperation( id, {
attachment: {
...item.attachment,
meta: {
...existingMeta,
ultrahdr: true,
hdr_capacity: info.hdrCapacity,
Comment thread
adamsilverstein marked this conversation as resolved.
Resolved
},
},
} );
return;
}

dispatch.finishOperation( id, {} );
};
}

/**
* Uploads an item to the server.
*
Expand Down Expand Up @@ -1170,6 +1246,13 @@ export function generateThumbnails( id: QueueItemId ) {
: thumbnailSource;
const batchId = uuidv4();

// Sub-sizes inherit the parent's UltraHDR status so that the
// resize step routes through libvips's uhdrload/uhdrsave pipeline
// (which preserves the gain map). Format transcoding is skipped
// for UltraHDR sources because converting to a different codec
// would strip the ISO 21496-1 gain map data.
const isUltraHdr = ultraHdrItems.has( item.id );

// Read per-file format conversion data from the attachment response.
const outputMimeType = attachment.image_output_format;
const interlaced = attachment.image_save_progressive ?? false;
Expand All @@ -1184,7 +1267,7 @@ export function generateThumbnails( id: QueueItemId ) {
]
| null = null;

if ( outputMimeType ) {
if ( ! isUltraHdr && outputMimeType ) {
thumbnailTranscodeOperation = await getTranscodeImageOperation(
thumbnailSource,
outputMimeType,
Expand Down Expand Up @@ -1218,14 +1301,15 @@ export function generateThumbnails( id: QueueItemId ) {
for ( const [ , names ] of dimensionGroups ) {
const imageSize = allImageSizes[ names[ 0 ] ];

// Build operations list for this thumbnail.
// Build operations list for this thumbnail. The resize step
// is UltraHDR-aware and will preserve the gain map automatically.
const thumbnailOperations: Operation[] = [
[ OperationType.ResizeCrop, { resize: imageSize } ],
];

// Add transcoding if format conversion is configured and
// the transparency check passed.
if ( thumbnailTranscodeOperation ) {
if ( ! isUltraHdr && thumbnailTranscodeOperation ) {
// Add transcoding if format conversion is configured and
// the transparency check passed.
thumbnailOperations.push( thumbnailTranscodeOperation );
}

Expand Down Expand Up @@ -1269,7 +1353,8 @@ export function generateThumbnails( id: QueueItemId ) {
? renameFile( thumbnailSource, attachment.filename )
: thumbnailSource;

// Add scaling to queue.
// Add scaling to queue. The resize step is UltraHDR-aware
// and will preserve the gain map automatically.
const scaledOperations: Operation[] = [
[
OperationType.ResizeCrop,
Expand All @@ -1283,8 +1368,8 @@ export function generateThumbnails( id: QueueItemId ) {
],
];

// Add transcoding if format conversion is configured.
if ( thumbnailTranscodeOperation ) {
if ( ! isUltraHdr && thumbnailTranscodeOperation ) {
// Add transcoding if format conversion is configured.
scaledOperations.push(
thumbnailTranscodeOperation
);
Expand Down
Loading
Loading