mirror of
https://github.com/nextcloud/server.git
synced 2026-10-15 02:57:15 +02:00
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>
39 lines
768 B
PHP
39 lines
768 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
namespace OC\Preview;
|
|
|
|
//.jp2
|
|
class JP2 extends Bitmap {
|
|
#[\Override]
|
|
public function getMimeType(): string {
|
|
return '/image\/jp2/';
|
|
}
|
|
|
|
#[\Override]
|
|
protected function getAllowedMimeTypes(): string {
|
|
return '/image\/jp2/';
|
|
}
|
|
|
|
#[\Override]
|
|
protected function getMagicStrings(): array {
|
|
return [
|
|
// The JP2 signature box, which opens the file: its length, the
|
|
// box type, and the four bytes that catch a transfer having
|
|
// mangled the line endings
|
|
"\x00\x00\x00\x0CjP \x0D\x0A\x87\x0A",
|
|
];
|
|
}
|
|
|
|
#[\Override]
|
|
protected function getImagickFormatHint(): string {
|
|
return 'jp2';
|
|
}
|
|
}
|