ImageSharp icon indicating copy to clipboard operation
ImageSharp copied to clipboard

No Tiff support.

Open JimBobSquarePants opened this issue 10 years ago • 45 comments

From @JimBobSquarePants on August 31, 2016 1:49

We should be able to support TIFF

Useful links.

http://partners.adobe.com/public/developer/tiff/index.html

http://www.remotesensing.org/libtiff/

http://www.awaresystems.be/imaging/tiff.html

Current implementation can be found in the tiff-codec branch.

Feature Checklist

  • [x] Reading TIFF file structure
  • [x] Parsing of relevant metadata
  • [x] Extraction of image data blocks
  • [x] Construction of image (from strip data)
  • [ ] Construction of image (from tile data)

Compression Types

  • [x] None
  • [x] Ccitt1D
  • [x] PackBits
  • [x] CcittGroup3Fax
  • [ ] CcittGroup4Fax
  • [x] Lzw
  • [ ] Old Jpeg
  • [ ] Jpeg (Technote 2)
  • [x] Deflate (Technote 2)
  • [x] Old Deflate (Technote 2)

Photometric Interpretation Formats

  • [x] WhiteIsZero
  • [x] BlackIsZero
  • [x] Rgb (Chunky)
  • [x] Rgb (Planar)
  • [x] PaletteColor
  • [ ] TransparencyMask
  • [ ] Separated (TIFF Extension color spaces)
  • [ ] YCbCr (TIFF Extension color spaces)
  • [ ] CieLab (TIFF Extension color spaces)
  • [ ] IccLab (TechNote 1)

JimBobSquarePants avatar Oct 30 '16 06:10 JimBobSquarePants

From @kierenj on September 7, 2016 20:27

I realise how unhelpful this comment right here is, but TIFF decoding across the board can be really tricky to get right - there are loads of compression formats, and even fairly respected tools (from MS / Atalasoft) get it wrong even with 1-bit images. I think some archiving formats even require special licensing to implement correctly. It might be worth identifying a small subset of formats to support!

JimBobSquarePants avatar Oct 30 '16 06:10 JimBobSquarePants

@kierenj It's certainly not an unhelpful comment. Tiff would be hard and I'm sorely tempted to let someone else figure it out and concentrate on what we have already. I'm just dreading the day someone tells me that the library is useless without it. There's always someone!

JimBobSquarePants avatar Oct 30 '16 06:10 JimBobSquarePants

I needed to import Tiff files so I created a temporary Tiff encoder and decoder based on LibTiff.Net.

ChrisVanDijk avatar Feb 22 '17 09:02 ChrisVanDijk

@chrisvandijk Good effort but have you benchmarked that codec? The Bitmiracle jpeg codec was about 10x slower and used 190MB more to process a small test image compared to our codec. I imagine the Tiff one will be the same. I'd be careful using it.

@Andy-Wilkinson you have been playing around with Tiff haven't you with your own stuff? I wonder if we can use some of it?

JimBobSquarePants avatar Feb 22 '17 12:02 JimBobSquarePants

@JimBobSquarePants The code and performance is bad, but I really needed the ability to open Tiff files. It's a temporary solution until a better one.

ChrisVanDijk avatar Feb 22 '17 12:02 ChrisVanDijk

@chrisvandijk understandable. Tiff is a complex format so I'm pushing it to the backburner until I can get everything else out of the way... Not looking forward to tackling it!

JimBobSquarePants avatar Feb 22 '17 13:02 JimBobSquarePants

@chrisvandijk @JimBobSquarepants One big "advantage" of these naive C ports is that its really not that hard to make the first steps towards speeding & cleaning them up. Someone with time & a profiler could check it, and estimate the efforts needed reuse/refactor elements of that code.

antonfirsov avatar Feb 22 '17 21:02 antonfirsov

@JimBobSquarePants I've got the basics of reading the Tiff format itself working from my own project (I started here since many Camera Raw files are mutant Tiff files). As you mention, there are a number of compression formats, but the key ones probably aren't too much trouble. The one issue with my existing codebase is that it was a bit of an experiment in a more functional style of C#, rather than how you might structure it normally.

All that said, I know a fair amount about the Tiff format now, so probably would be able to make a quick start on a true ImageSharp Tiff codec pretty easily (and share a bit of the code where I can). Would you be interested in me picking up this issue and giving it a start? (especially since you guys seem to be busy enough with the existing codec perf 😄)

Andy-Wilkinson avatar Feb 22 '17 21:02 Andy-Wilkinson

@antonfirsov I've found with those ports though there's about a million lines more code than I'd like to read nested in there.

@Andy-Wilkinson That would be absolutely brilliant if you could! 💯

JimBobSquarePants avatar Feb 22 '17 22:02 JimBobSquarePants

I come across this library https://github.com/BitMiracle/libtiff.net which is already .netstandard compatible. It's under new BSD license https://github.com/BitMiracle/libtiff.net/blob/master/license.txt

I feel like this is a good candidate to bring support for TIFF.

What do you think?

sandorfr avatar Aug 03 '17 06:08 sandorfr

@sandorfr We've already got a WIP TIFF PR in progress #119

The BitMiracle repositories, to put it nicely, are junk. Poorly ported, slow, bloated implementations that are useful only for testing against.

JimBobSquarePants avatar Aug 03 '17 06:08 JimBobSquarePants

@poeman16 : Unfortunately I've had pretty much zero time to devote to working on this pull request for a while. The foundations of parsing the TIFF structure was mostly in place, with the most complex area remaining being implementations for the different compression formations, in particular those based on JPEG. There would need to be some changes to fit with any changes in the ImageSharp design since the last commit. Definitely something that could be picked up by someone.

Andy-Wilkinson avatar Aug 12 '18 14:08 Andy-Wilkinson

There's been a lot of changes in the main repo since the PR was opened. We'll have to do a lot of work to update the codebase before support can be completed.

JimBobSquarePants avatar Aug 12 '18 14:08 JimBobSquarePants

Are there any plans to support TIFF in the future, im using your library for viewing/editing Exif data

darl0026 avatar Jan 25 '19 16:01 darl0026

Yep, we have a Tiff branch with a lot of code written already. Post v1 we will work to complete it.

JimBobSquarePants avatar Jan 25 '19 21:01 JimBobSquarePants

Hi @JimBobSquarePants as the others I am interested on a Tiff decoder. I need to process multipage Tiff documents from office scanner. Thanks in advance.

damianog avatar Apr 22 '19 15:04 damianog

@antonfirsov @JimBobSquarePants @Andy-Wilkinson Can I contribute to the tiff-codec branch? I would like to commits to my branch IldarKhayrutdinov/ImageSharp/tiff-codec then create PR to the SixLabors/ImageSharp/tiff-codec.

IldarKhayrutdinov avatar Aug 09 '19 15:08 IldarKhayrutdinov

@IldarKhayrutdinov that would be ace! 🚀

antonfirsov avatar Aug 10 '19 00:08 antonfirsov

Just a comment, I don't see it named, but there are multipage TIFF files, used extensively by a lot of scanning software, so should be accounted for?

claunia avatar Aug 15 '19 10:08 claunia

@claunia Yes, at the moment the multipages aren't supported, I'm working on it 🙂

IldarKhayrutdinov avatar Aug 15 '19 10:08 IldarKhayrutdinov