Skip to content

feat(preview): generate previews for JPEG 2000 images - #64603

Open
skjnldsv wants to merge 3 commits into
masterfrom
feat/jp2-previews
Open

skjnldsv wants to merge 3 commits into
masterfrom
feat/jp2-previews

Conversation

@skjnldsv

@skjnldsv skjnldsv commented Sep 20, 2026

Copy link
Copy Markdown
Member
  • Resolves: #

Summary

You can upload a .jp2 today and Nextcloud types it correctly, and then nothing can render it, so it opens to nothing. No preview provider claims image/jp2.

ImageMagick reads the format where it was built with OpenJPEG, so this adds OC\Preview\JP2 on the existing Bitmap base, the same shape as TIFF. libgd was never an option: it has no JPEG 2000 support at all, which is why the case for it in OC\Image sits commented out. Imaginary answers 406 for one.

Like the other ImageMagick providers it stays off until an admin adds it to enabledPreviewProviders, so this is not on-by-default support.

I also renamed AvifPreviewTrait to PreviewPixelsTrait. The assertion in it was never AVIF specific and the new test uses it too.

TODO

  • Nothing outstanding

Checklist

I ran the tests on a throwaway sqlite instance inside the CI image, which has JP2 in its ImageMagick, rather than leaving it to CI. JP2Test passes: four thumbnail sizes, plus a check that the preview actually contains the picture rather than a blank canvas of the right shape, which is all the shared provider test would catch. The AVIF and HEIC tests still pass after the rename.

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

A .jp2 is typed correctly on upload and has been since 12.0.0.14, and
then nothing can render it: no provider claims image/jp2, no browser
decodes the format, so the file opens to nothing.

ImageMagick reads it where it was built with OpenJPEG, which is what the
other formats libgd cannot read already rely on, and the signature box a
.jp2 opens with sits at offset 0 where Bitmap looks for it. So this is
the same shape as TIFF: a Bitmap subclass naming the format, off until
an admin enables it.

libgd is not an option here and never was. It has no JPEG 2000 functions
at all, which is why the case for it in OC\Image sits commented out
beside the other formats it cannot read. Imaginary answers 406 for one.

The pixel assertion the AVIF tests use is not about AVIF, so it loses
the name and is shared.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
It went in beside Imaginary rather than after ImaginaryPDF, which
php-cs-fixer and the strict run both objected to.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
They were overwritten by a copy of another checkout's vendor-bin, made
to run php-cs-fixer locally, and swept into the previous commit. That
pinned psalm back to 6.16.1 while the baseline is written by 6.17.0,
which is what the static analysis was objecting to.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants