#1000873 black.jph: JPEG 2000 codestream

Package:
file
Source:
file
Description:
Recognize the type of data in a file using "magic" numbers
Submitter:
Mathieu Malaterre
Date:
2021-12-01 08:33:03 UTC
Severity:
normal
#1000873#5
Date:
2021-11-30 15:01:21 UTC
From:
To:
Dear Maintainer,

It would be nice if the following file would be properly recognized a
HTJ2K (and not simply JPEG 2000 codestream).

For reference:

* https://www.iana.org/assignments/media-types/image/jph

Steps:

$ gunzip black.jph.gz
$ file black.jph
black.jph: JPEG 2000 codestream

Expected something like:

black.jph: HT JPEG 2000 codestream

For reference JPEG 2000 and HT JPEG 2000 are not compatible:

```
% opj_decompress -i black.jph -o black.pgm

===========================================
The extension of this file is incorrect.
FOUND .jph. SHOULD BE .j2k or .jpc or .j2c
===========================================

[INFO] Start to read j2k main header (0).
[WARNING] Unknown marker
[ERROR] Error reading SPCod SPCoc element, Invalid code-block style found
[ERROR] Error reading COD marker
[ERROR] Marker handler function failed to read the marker segment
ERROR -> opj_decompress: failed to read the header
```

For refence open source implementation used for generate this file:

* https://github.com/aous72/OpenJPH

Steps:

% convert -size 512x512 -depth 8 xc:black black.pgm
% ojph_compress -prog_order LRCP -reversible true -i black.pgm -o black.jph

#1000873#10
Date:
2021-12-01 08:05:40 UTC
From:
To:
I need to clarify the above sentence. I used as an example the fact
that `opj_decompress` would fail on one such example. This will no
longer be the case when openjpeg 2.5.0 is released:

* https://github.com/uclouvain/openjpeg/pull/1381

So to repeat what I said previously the attached file should return
(to indicate this is not a Part1 JPEG 2000 codestream):

% file black.jph
black.jph: HTJ2K codestream
% file --mime-type black.jph
black.jph: image/jph

For reference openjpeg code source:

* https://github.com/uclouvain/openjpeg/pull/1381/files#diff-ceb848d51b7032f98b881cf63dad4806ca3223178418dcd521561cd6e8cf97b6

Conformance HTJP2K samples can be found at:

* https://github.com/osamu620/OpenHTJ2K/tree/main/conformance_data

@aous72, can you point us to the location of true "HTJ2K with JP2
boxes" files (HTJP2K with JPH header) ?

Thanks.

#1000873#15
Date:
2021-12-01 08:30:00 UTC
From:
To:
 Hi Mathieu,
OpenJPH and OpenHTJ2K currently only generates HTJ2K codestreams.
I am not very sure if grok (https://github.com/GrokImageCompression/grok) generates a .jph header.I know Kakadu does (https://kakadusoftware.com/); you can get a demo app.

In any case, this is the same black.jph file but with proper header.

Kind regards,Aous.



    On Wednesday, December 1, 2021, 07:05:51 PM GMT+11, Mathieu Malaterre <malat@debian.org> wrote:

 > For reference JPEG 2000 and HT JPEG 2000 are not compatible.

I need to clarify the above sentence. I used as an example the fact
that `opj_decompress` would fail on one such example. This will no
longer be the case when openjpeg 2.5.0 is released:

* https://github.com/uclouvain/openjpeg/pull/1381

So to repeat what I said previously the attached file should return
(to indicate this is not a Part1 JPEG 2000 codestream):

% file black.jph
black.jph: HTJ2K codestream
% file --mime-type black.jph
black.jph: image/jph

For reference openjpeg code source:

* https://github.com/uclouvain/openjpeg/pull/1381/files#diff-ceb848d51b7032f98b881cf63dad4806ca3223178418dcd521561cd6e8cf97b6

Conformance HTJP2K samples can be found at:

* https://github.com/osamu620/OpenHTJ2K/tree/main/conformance_data

@aous72, can you point us to the location of true "HTJ2K with JP2
boxes" files (HTJP2K with JPH header) ?

Thanks.