mirror of
https://github.com/nextcloud/server.git
synced 2026-10-04 17:58:59 +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>
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace Test\Preview;
|
|
|
|
use OC\Preview\JP2;
|
|
|
|
/**
|
|
* Class JP2Test
|
|
*
|
|
* @package Test\Preview
|
|
*/
|
|
#[\PHPUnit\Framework\Attributes\Group('DB')]
|
|
class JP2Test extends Provider {
|
|
use PreviewPixelsTrait;
|
|
|
|
#[\Override]
|
|
protected function setUp(): void {
|
|
if (!extension_loaded('imagick')) {
|
|
$this->markTestSkipped('ImageMagick is not installed. Skipping tests');
|
|
}
|
|
if (!in_array('JP2', \Imagick::queryFormats('JP2'), true)) {
|
|
$this->markTestSkipped('ImageMagick was built without JPEG 2000. Skipping tests');
|
|
}
|
|
|
|
$fileName = 'testimage.jp2';
|
|
$sourcePath = \OC::$SERVERROOT . '/tests/data/' . $fileName;
|
|
|
|
// Reporting the coder is not the same as being able to use it: the
|
|
// OpenJPEG delegate may be missing, or policy.xml may have disabled
|
|
// it, in which case decoding throws and the tests would fail rather
|
|
// than skip. Decode once for real before committing to them.
|
|
try {
|
|
(new \Imagick())->readImage('jp2:' . $sourcePath . '[0]');
|
|
} catch (\ImagickException $e) {
|
|
$this->markTestSkipped('ImageMagick cannot decode JPEG 2000 here: ' . $e->getMessage() . '. Skipping tests');
|
|
}
|
|
|
|
parent::setUp();
|
|
|
|
$this->imgPath = $this->prepareTestFile($fileName, $sourcePath);
|
|
$this->width = 1680;
|
|
$this->height = 1050;
|
|
$this->provider = new JP2();
|
|
}
|
|
|
|
public function testPreviewCarriesThePicture(): void {
|
|
$this->assertPreviewShowsThePicture();
|
|
}
|
|
}
|