loris-imageserver / loris

Loris IIIF Image Server
Other
208 stars 87 forks source link

Can we use Pillow for JP2 parsing? #372

Open alexwlchan opened 6 years ago

alexwlchan commented 6 years ago

Currently img_info.py has a big chunk of code for parsing JP2s.

Originally, Loris only supported Pillow 2.1 or newer. Pillow added JP2 support in 2.4.0, which is now the minimum required version in Loris.This means that every (up-to-date) Loris is running with a version of Pillow that has native JP2 support.

Could we switch to using Pillow for JP2 parsing? Should we?

It would be nice to hand that code off to another library, since JP2 parsing is really orthogonal to Loris’s core purpose.

alexwlchan commented 6 years ago

To partially answer my own question: Pillow doesn’t seem to expose (or know about) the colour profile information used by Loris, so we’d have to retain that at least.

Nor does it have tiles. Guess it’s JPEG2000 support isn’t good enough for us (yet!).

jpstroop commented 6 years ago

Last I checked (12 mos?), Pillow's integration w/ OpenJPEG is pretty naive. I think you can get w/h and that's about it. And as far as pulling out tiles or anything like that goes, it doesn't know about tiles or precincts or decomposition levels, etc.

nmaekawa commented 6 years ago

Hi, I'm working on this as a devops point of view and don't know much about images. I have the jp2 tests images that come with loris and understand that if you don't plan to support jp2 as source format, you probably should not have them in the image storage.

But, is there a way to disable jp2 as a source format? I'm removing the jp2 entry from the transformers section in loris.conf so it throws a 500 (for KeyError). It's not pretty but it returns faster than trying to transform the jp2 then failing or timing out. Is there a less ugly way to do it?

bcail commented 6 years ago

@nmaekawa could you please open a separate issue? Maybe you could give more details about why you want to disable JP2 as a source format. You don't have to have any JP2 source images - you can just ignore JP2s as it is.