# Nerdy facts jpeg-2000, openexr

- Link: https://tongfamily.com/2016/03/12/nerdy-facts-jpeg-2000-openexr/
- Published: 2016-03-12T09:19:54-08:00
- Author: rich

OK way too many nerd thoughts today:

 1. 16-bit vs 8-bit color and 5400 vs 2700 dpi resolution scanning. I’m scanning lots
    of old photos. Until now I’ve been using JPEG because they are small, but the lack
    of 16-bit color has really bothered me. Even snapshots with crappy cameras show
    light and dark issues with only 8-bits and these are archival. But Vuescan creates
    214MB TIFs with 5400 dpi. So I need to turn the dpi down (5400 is a lot given that
    a crappy lense is certainly not going to generate a 44 megapixel resolution!). 
    So moving to 2700 (or 27^2*1.5=10MP) seems more reasonable. That stinks the 214MB
    TIF to just 50MB. Which in todays world is actually OK.
 2. JPEG vs [JPEG2000](http://www.openjpeg.org) vs OpenEXR vs TIF. The other solution
    is to go to a lossy 16-bit format. The main problem is that JPEG is *still* just
    8 bits. There are some not great choices here, but JPEG2000 is 16 bit and they 
    say OpenEXR might work. Way off in the weeds in terms of format and with today’s
    hard disk, maybe 50MB is OK. JPEG 2000 has a C level open source implementation
    called Open JPEG and a command line interface so the workflow is Vuescan to TIF
    then batch convert to JPEG 2000.
 3. [OpenEXR](http://www.openexr.com/index.html). I have used this for HDR images, 
    but it also works for regular ones. It was developed by Industrial Light and Magic
    and apparent [Mac Preview ](http://osxdaily.com/2010/01/24/convert-images-in-mac-os-x-jpg-to-gif-psd-to-jpg-gif-to-jpg-bmp-to-jpg-png-to-pdf-and-more/)
    will write it which made me super happy until I tried it and discovered Preview
    only write 8 bit color for JPEG-2000 and OpenEXR. It just grays out 16-bit!

So on to other options to get OpenEXR or JPEG 2000 in order of trying things:

 1. [Openjpeg](https://github.com/uclouvain/openjpeg/). It is the reference implementation
    of JPEG 2000. It is a command line thing and you can just `sudo port install openjpeg`
    and it appears on your Mac. The main problem is that it [does not support color profiles](http://wiki.opf-labs.org/display/TR/Handling+of+ICC+profiles)
    and strips them from the TIF files. I use ProPhoto [profile](http://openpreservation.org/blog/2013/07/01/icc-profiles-and-resolution-jp2-update-2011-d-lib-paper/)
    as this uses lots more colors and is suitable for 16-bit display. Only Adobe Photoshop
    seems to support it correctly. Also by default it does lossless compression. That
    compression is better than TIFs. A 220MB TIF becomes a 175MB JP2. If you want some
    compressions, then the parameters looks like `[opj_compress -i <input> -o <output>.jp2 -r 3](https://github.com/uclouvain/openjpeg/wiki/DocJ2KCodec)`
    for 3x reduction. However you lose the color profile. I did try to add a profile
    with [exiftool](http://stackoverflow.com/questions/6740441/how-to-set-a-color-profile-with-exiftool)
    which failed on the j2k image but appeared to work on the jp2 image, but when using
    preview, it didn’t show any ICC profile. And when opened with Photoshop, it shows
    an sRGB profile which is not right. Even converting to ProPhotoRGB does not fix
    it.
 2. OpenEXR. This is just a library, but you can get it with `sudo port install openexr`.
    However it doesn’t have a user interface. Again it looks like using a Photoshop
    plugin is a better approach.
 3. [GIMP](https://www.gimp.org/downloads/). I had forgotten about gimp which an open
    source image editing application like Photoshop. And with mac ports, it is a simple`
    sudo port install gimp` to get it and it appears to have a JPEG 2000 plugin.
 4. [GIMP 2.9](https://www.gimp.org/news/2015/11/27/gimp-2-9-2-released/). It looks
    like their latest version moves to 32-bit color processing and supports OpenEXR.
    Perhaps a better format long term as ILM is using it for everything. This is a 
    little trickier to get as it is an intermediate point before 2.10, but you basically
    can [git clone](https://git.gnome.org/browse/gimp/) and then compile it however
    the dependencies definitely make it [hard to build](https://www.gimp.org/source/).
    But perhaps, the [jenkins docker image](https://github.com/samrocketman/docker-jenkins-gimp)
    is the answer. Docker really does solve so many problems. I’ll drop for now until
    2.10 comes out as building is a pain.
 5. Lightroom. I tried it but wasn’t surprised to find that JPEG-2000 isn’t supported
    as an export type by lightroom. Just JPEG and TIF.
 6. Photoshop. Well I try to get away from Photoshop, but I guess it is impossible.
    Photoshop reads and writes 16-bit JPEG 2000 and include the ICC profile in it. 
    So sometimes, the most obvious answer is right there in front of you. At first 
    it looks like it only produces 8-bit JPEG 2000 files so that is disappointing as
    reported by Mac Preview, but when I look in Image/Mode and File/Info on Photoshop
    it says it is in fact 16-bit, so looks like a problem with Mac Preview.

So the workflow is a little clunky now. Scan old images with Vuescan at 5400 dpi
to 48-bit RGB TIF. Then use Photoshop to open this monster 220MB file and save as
a JPEG 2000 with 90% reduction. While it is not lossless, I would certainly trade
the higher resolution and color depth for the size.
 It looks like setting it for
lossless compression gets a 5400 dpi 35mm slide at 16 bits per color down from 220MB
with TIF to 170MB with lossless JPEG-2000 and 40MB with JPEG-2000 set at 90% image
quality. That’s actually not too bad given today’s hard disks. I was getting about
12MB for a 5400 dpi 8-bit color, but of course this is JPEG-2000 is supposed to 
handle artifacts better so it is going to be a bit more than doubling the file size.

### Share this:

 * [  Mastodon ](https://tongfamily.com/2016/03/12/nerdy-facts-jpeg-2000-openexr/?share=mastodon)
 * [  LinkedIn ](https://tongfamily.com/2016/03/12/nerdy-facts-jpeg-2000-openexr/?share=linkedin)
 * [  Facebook ](https://tongfamily.com/2016/03/12/nerdy-facts-jpeg-2000-openexr/?share=facebook)
 * [  WhatsApp ](https://tongfamily.com/2016/03/12/nerdy-facts-jpeg-2000-openexr/?share=jetpack-whatsapp)
 * [  Email ](https://tongfamily.com/2016/03/12/nerdy-facts-jpeg-2000-openexr/?subject=%5BShared%20Post%5D%20Nerdy%20facts%20jpeg-2000%2C%20openexr&body=https%3A%2F%2Ftongfamily.com%2F2016%2F03%2F12%2Fnerdy-facts-jpeg-2000-openexr%2F&share=email)
 * [More](https://tongfamily.com/2016/03/12/nerdy-facts-jpeg-2000-openexr/#)

 * [  Telegram ](https://tongfamily.com/2016/03/12/nerdy-facts-jpeg-2000-openexr/?share=telegram)
 * [  Print ](https://tongfamily.com/2016/03/12/nerdy-facts-jpeg-2000-openexr/#print?share=print)
 * [  Pinterest ](https://tongfamily.com/2016/03/12/nerdy-facts-jpeg-2000-openexr/?share=pinterest)
 * [  Tumblr ](https://tongfamily.com/2016/03/12/nerdy-facts-jpeg-2000-openexr/?share=tumblr)
 * [  X ](https://tongfamily.com/2016/03/12/nerdy-facts-jpeg-2000-openexr/?share=twitter)

### Like this:

Like Loading…
