TIF file with JPEG2000 compression

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
BonafideSupraman
Posts: 2
Joined: 2018-04-06T11:50:37-07:00
Authentication code: 1152

TIF file with JPEG2000 compression

Post by BonafideSupraman »

I have a number of TIF files with a compression tag of 34712 (JPEG2000). These images show up completely black in the majority of viewers.
I'm trying to convert these to any other format but get the error: Compression scheme 34712 scanline decoding is not implemented.
Does anyone know how I can convert these files? Is it possible to change the container without trying to decompress the image?

Code: Select all

Dump info:
Magic: 0x4949 <little-endian> Version: 0x2a <ClassicTIFF>
Directory 0: offset 8 (0x8) next 0 (0)
SubFileType (254) LONG (4) 1<2>
ImageWidth (256) LONG (4) 1<1276>
ImageLength (257) LONG (4) 1<1650>
BitsPerSample (258) SHORT (3) 1<8>
Compression (259) SHORT (3) 1<34712>
Photometric (262) SHORT (3) 1<3>
StripOffsets (273) LONG (4) 1<1770>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<1>
RowsPerStrip (278) LONG (4) 1<1650>
StripByteCounts (279) LONG (4) 1<659301>
XResolution (282) RATIONAL (5) 1<150>
YResolution (283) RATIONAL (5) 1<150>
PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<2>
PageNumber (297) SHORT (3) 2<0 0>
Colormap (320) SHORT (3) 768<0 256 512 768 1024 1280 1536 1792 2048 2304 2560 2816 3072 3328 3584 3840 4096 4352 4608 4864 5120 5376 5632 5888 ...>
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: TIF file with JPEG2000 compression

Post by fmw42 »

I do not know if Imagemagick via libtiff supports JPG2000 compression. You would have to check with the libtiff software to see. Imagemagick uses libtiff to read TIFF files and decompress them. Also see this other post viewtopic.php?f=1&t=16800

This shows that there is an option for JPG2000 compression in libtiff. See https://www.awaresystems.be/imaging/tif ... ssion.html

Perhaps you need to upgrade your libtiff delegate for Imagemagick
Jason S
Posts: 103
Joined: 2010-12-14T19:42:12-07:00
Authentication code: 8675308

Re: TIF file with JPEG2000 compression

Post by Jason S »

I don't think that libtiff directly supports JPEG2000 compression.

Can you point me to a sample file, or some format documentation?

I'd guess that a single-strip TIFF/JPEG2000 image like yours simply contains an embedded "JPEG 2000 codestream". If so, it should have the byte pattern 0xFF 0x4F 0xFF at offset 1770 (per the StripOffset). If you make a copy of your file, delete the first 1770 bytes, and give it a .j2c extension, it should be readable by JPEG2000 software. You would lose any metadata or other information contained only in the TIFF wrapper, though.
Jason S
Posts: 103
Joined: 2010-12-14T19:42:12-07:00
Authentication code: 8675308

Re: TIF file with JPEG2000 compression

Post by Jason S »

To clarify my libtiff comment, I mean that libtiff does not have an option to compile in JPEG2000 compression support. An app like ImageMagick could presumably implement its own JPEG2000 codec, and register it with libtiff at runtime. But the current version of IM does not appear to ever do that.
BonafideSupraman
Posts: 2
Joined: 2018-04-06T11:50:37-07:00
Authentication code: 1152

Re: TIF file with JPEG2000 compression

Post by BonafideSupraman »

@fmw42 Funnily enough, I've tried the newest version of libtiff and it still doesn't know how to handle this file.

@Jason S Thanks Jason, your suggestion did the trick.
Post Reply