1
\$\begingroup\$

I sometimes use the Nik collection to process my photos, and because this runs on TIFF images, I end up with demosaiced files eating up more disk space than they're worth.

I want to batch convert these files for archival. JPEG2000 sounds good on paper, but I think the basic imagemagick invocation isn't good.

Comparison

Source file: https://drive.google.com/file/d/1KqYEQealzgptpt8DjJp30yy-QNP-D2Dq/view?usp=sharing (178MB)

16-bit TIF source

Crop of shadows boosted from TIF file:

TIF image crop

8-bit JPG

Crop of shadows boosted from a JPEG conversion shows good detail but color blocking (magick convert DSC02449-Pano-Edit-2.tif -quality 97 DSC02449-Pano-Edit-2.jpg, output 8.2M):

JPG converted image crop

16-bit JPEG-2000 (imagemagick encoder)

The JP2 image has horrible loss of detail (magick convert DSC02449-Pano-Edit-2.tif -define jp2:quality=50 DSC02449-Pano-Edit-2.jp2, output 8.0M).

JP2 converted image crop

16-bit JPEG-2000 (Photoshop encoder)

The Photoshop JPEG 2000 encoder looks good. There is some loss of detail in the streams of water, but this seems more than acceptable at the compression ratio, and there are no obvious artifacts (blocking, color errors, severe loss of detail). I had it match the output size of the JPG (8.3M).

JPF photoshop encoder converted image crop

8-bit HEIC

I don't know how to adjust the quality settings of the HEIC encoder, it just seemed to have one preset. It seems to be off in color but has decent detail and no blocking (magick convert DSC02449-Pano-Edit-2.tif DSC02449-Pano-Edit-2.heic, 12.1M). Loading the image in Photoshop, or converting back to TIF suggests it only has 8-bit depth.

HEIC converted image crop

Questions

While JPG looks like a decent option here, I think there's a risk that if I'm running it in batch on a bunch of images I don't look at, it could lose a lot of information if there's a dark image where I haven't adjusted the shadows properly or something.

  • Is there a better invocation of the ImageMagic JPEG2000 encoder? (Or a way to invoke the Photoshop encoder in batch?)
  • Can I archive these images as single-frame x265 movies? I've heard that encoder is very efficient and supports high bit depths. This is an inconvenient format, but I am mostly archiving these images and unlikely to interact with them much.

(I'm using ImageMagick 7.0.9-10 Q16 x86_64 2019-12-23 installed via HomeBrew for OS X 10.15 "Catalina". Related question for different goal and without comparison images: Is there a lossy compressed file format for 16-bit dynamic range images?)

\$\endgroup\$
3
  • \$\begingroup\$ Are you looking for something to replace your high-quality images, or merely supplement them for ease of access? \$\endgroup\$ Dec 24, 2019 at 19:08
  • \$\begingroup\$ Replace ... I don't access these often, and they seem like a waste of space. (Plus I still have the source RAW files, which are not demosaiced, so I could theoretically recreate them with the same Nik collection edits) \$\endgroup\$ Dec 24, 2019 at 19:24
  • 1
    \$\begingroup\$ It probably doesn't really matter then, 8bit is fine for general viewing, even (most) printing. The loss of detail is usually only an issue if you're editing the images, so you can go back to the raw files if you ever need access to that low level detail for anything. Just save them with very low compression. \$\endgroup\$ Dec 24, 2019 at 20:10

4 Answers 4

3
\$\begingroup\$

May I suggest HEIF?

HEIF is the replacement for both JPEG and JPEG2000. It is effectively a single H.265 frame.

Don't store single-frame H.265 movies! Instead, use the proper file format that has been designed to use the same algorithms that H.265 uses.

\$\endgroup\$
4
  • \$\begingroup\$ Looks great on paper ... How do I run it? \$\endgroup\$ Dec 24, 2019 at 19:25
  • \$\begingroup\$ @gatoatigrado The Wikipedia page says ImageMagick supports this format, so if you have a recent version, you should be able to use it. My ImageMagick of Ubuntu 18.04 LTS does not yet have HEIF support. \$\endgroup\$
    – juhist
    Dec 24, 2019 at 19:37
  • 1
    \$\begingroup\$ I was unfamiliar with this format. I just added the plugin for it to Gimp. As a quick test I exported a raw NEF (32.6 MB) to aTIF-16 uncompressed (149 MB) then used GIMP to export the TIF to lossless HEIC (20 MB). Very Cool, thanks! \$\endgroup\$ Dec 24, 2019 at 22:29
  • \$\begingroup\$ Seems like the imagemagick encoder doesn't actually write 16-bit files, and has some issues with color profiles. I hope this becomes a better option in the future though! Added crops to the question. (I can't add them as comments here.) \$\endgroup\$ Dec 25, 2019 at 1:49
1
\$\begingroup\$

Specifically with reference to JPEG2000, this page lists several other alternatives. I've used jasper some, but haven't played with the rest, so I can't specifically recommend any particular one.

\$\endgroup\$
0
\$\begingroup\$

I found that using a sigmoidal curve to preserve highlights and shadows, and using webp compression gave an excellent result. The downside is that the sigmoidal contrast value needs to be saved for decoding, so I'll probably save a sidecar file. (This will also be a useful reminder.)

Encoding: magick convert DSC02449-Pano-Edit-2.tif +sigmoidal-contrast 5,50% -quality 99 -define webp:method=5 -define webp:partitions=3 -define webp:image-hint=photo DSC02449-Pano-Edit-2.webp

Decoding: magick convert DSC02449-Pano-Edit-2.webp -depth 16 -sigmoidal-contrast "5,50%" DSC02449-Pano-Edit-2-webpdecode.tif

The result is 5.6M, it encodes in 8.6 seconds on my 2015 MacBook Pro, and the decoded image has the correct color profile, is free of obvious artifacts (including color shift in the shadows), and reasonably detailed. Replacing the options with -define webp:lossless=true will yield a ~20M file (still a good reduction from the 178M source) that has slightly more detail.

webp shadow detail

\$\endgroup\$
0
\$\begingroup\$

This seems too obvious to me, but have you considered just doing a basic Zip on the images in question?

You're talking about archiving them and that you don't access them very often anyway, so there is no apparent need to instantly see the actual image. Plus all modern file viewers allow you to dive into a Zip file seamlessly.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.