Hi,
16-bit (lossless) JPEG isn't supported by current libtiff. I guess it
could by tweaking tif_jpeg.c
That said, 16-bit lossless JPEG doesn't shine by any aspect. You'd be
much better using other lossy codecs. In GDAL we've experimented with
JPEGXL. The codec is at
https://github.com/OSGeo/gdal/blob/master/frmts/gtiff/tif_jxl.c . I'll
probably try to upstream it once libjxl reaches its 1.0 milestone.
Even
Le 05/02/2024 à 22:18, Ellen Johnson via Tiff a écrit :
Hi Bob,
Thanks for the quick response!
We're building libtiff v4.6.0 with libjpeg-turbo v3.0.0. In fact,
we worked extensively with the libjpeg-turbo maintainer to enable
lossless support for 8-, 12-, and 16-bit images. And I modified our
JPEG source code to work with the new jpeg12_read_scanlines,
jpeg16_read_scanlines, etc. functions in libjpeg-turbo.
A few things to note that might be clues:
1. Previously in our libjpeg v6b, we had heavily patched it with Ken
Murchison's lossless patch to enable lossless support. But by
working with the libjpeg-turbo maintainer to enable lossless
support in libjpeg-turbo, we're now able to use libjpeg-turbo in
place of our heavily patched libjpeg v6b. And because
libjpeg-turbo allows run-time bit depth selection, we're able to
use the same libjpeg-turbo library for the three bit-depths
(instead of compiling it into three different bit-depth-specific
libraries).
2.
I didn't do anything special when configuring libtiff v4.6.0 to
build with libjpeg-turbo, other than to make sure I saw the "dual
mode" configuration specification – if I remember correctly when I
built libtiff v4.6.0, when it looked for libjpeg-turbo it made
sure some dual mode configuration was set to enable 8- and 12-bit
modes. Is there a config setting I might have missed that enables
working with 16-bit images?
3.
I'm also now building libtiff dynamically with libjpeg-turbo
(instead of the previous static linking with libjpeg v6.b).
4.
In our MATLAB imread test that's failing with the TIFF file that
has the "linearRaw" subIFD, there's a note that even with libtiff
built with libjpeg v6b, it was only able to decode the first 10
tiles of the linearRaw subIFD – for the rest of the tiles, it was
returning uninitialized memory. Unfortunately the developer who
wrote that test is out of office and I don't know the backstory on
where that TIFF file came from, or why libtiff built with libjpeg
v6b was only able to decode the first 10 tiles of the subIFD.
If you think of anything or if i missed a libtiff config setting for
reading 16-bit images, please let me know. I'm really puzzled as to
what's going on. I'm also reaching out to the libjpeg-turbo
maintainer for help with this.
Thank you!
ellen
------------------------------------------------------------------------
*From:* Bob Friesenhahn <[email protected]>
*Sent:* Monday, February 5, 2024 3:28 PM
*To:* Ellen Johnson <[email protected]>
*Cc:* [email protected] <[email protected]>
*Subject:* Re: [Tiff] error reading linearRaw subIFD from a TIFF file
with libtiff built with libjpeg-turbo?
On Mon, 5 Feb 2024, Ellen Johnson via Tiff wrote:
> Our imread function successfully reads the main image and the second
subIFD. But when reading the first subIFD, something goes awry – it
ends up calling libtiff's TIFFReadTile function in tif_read.c, which
then calls TIFFReadEncodedTile (also in tif_read.c). I haven't
debugged further yet, but something fails during TIFFReadEncodedTile
which results in our imread function give error that the file has no
readable tiles.
>
> I'm wondering if you know what may be going wrong here, and/or if
> there are any limitations with libtiff built with libjpeg-turbo that
> would cause problems reading a 16-bit linearRaw subIFD that is JPEG
> compressed.
Until libjpeg-turbo 2.1.5 (see
https://github.com/libjpeg-turbo/libjpeg-turbo/releases)
<https://github.com/libjpeg-turbo/libjpeg-turbo/releases)>, it was not
possible to easily support 16-bit JPEG. Since that version, it is
possible for one library to support 8, 12, and 16-bit JPEG.
Working properly with the above requires a libtiff which operates
correctly with the "new" (re-purposed) API. This would likely mean
that you need a recent libtiff, released since the new libjpeg-turbo
features were added.
What libjpeg-turbo are you using, and how was it configured?
Bob
--
Bob Friesenhahn
[email protected],
http://www.simplesystems.org/users/bfriesen/
<http://www.simplesystems.org/users/bfriesen>
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
<http://www.GraphicsMagick.org>
Public Key, http://www.simplesystems.org/users/bfriesen/public-key.txt
<http://www.simplesystems.org/users/bfriesen/public-key.txt>
_______________________________________________
Tiff mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/tiff
--
http://www.spatialys.com
My software is free, but my time generally not.
_______________________________________________
Tiff mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/tiff