CenterForOpenScience / modular-file-renderer

A Python package for rendering files to HTML via an embeddable iframe
http://modular-file-renderer.readthedocs.io/en/latest/
Apache License 2.0
44 stars 67 forks source link

[SVCS-52] Adding support for mutli-page tiff files. #275

Closed AddisonSchiller closed 6 years ago

AddisonSchiller commented 7 years ago

adding more to pdf renderer tiff files are now rendered by the pdf renderer, and the pdf extension now has an exporter to handle tif/tiff files. Tiff files are now converted to pdfs for viewing

refs: https://openscience.atlassian.net/browse/SVCS-52

Purpose

Add support for mutlipage tiff files.

Summary of changes

Tiff files are sort of like pdfs, and can be converted to them. The pdf extension now handles tiff files. The pdf extension now has an exporter for tiff files Reportlab has been added as a dependency. Some multipage tiffs will not render correctly. see testing notes.

Testing QA notes:

below is a copy and paste of my testing notes on the jira ticket. you can find the zip file over there

Testing Notes:

Attached to the jira ticket is a zip containing some tif/tiff files to use for testing.

Due to the aspects of what this commit is doing, the following should also be tested: Other pdf files. Try a few regular pdf files and make sure they render properly. Any files rendered by the unoconv renderer. (ie docx) The unoconv renderer ships files to the pdf renderer.

AddisonSchiller commented 7 years ago

@felliott Random comments/CRR

Take a look at the settings questions, not quite sure how you want me to handle that.

On libtiff: I took a look at it, and it was sort of inconclusive. All i could find is there seem to be some tiff files that label things not to the tiff standard. using libtiff might help with those? I don't think we are using it in our docker container atm (it might come auto installed though.)

I did try to install it and see if it changed the way any of my test tiff files rendered and it did not seem to.

Just couldn't find enough information about it. Some of the docs linked to other libraries i originally looked at for rendering tiffs etc, and such. If you want i could definitely spend more time on this.

Also, leaving in additional development while I wait for responses to some of my questions

coveralls commented 7 years ago

Coverage Status

Coverage increased (+1.8%) to 69.816% when pulling 114c4926d726b59e799a81529c12493a4ff6066b on AddisonSchiller:feature/multipage-tif into 8bb2dd4d35f8c1d89a72fc8b9e09db317f3497f3 on CenterForOpenScience:develop.

felliott commented 7 years ago

I've worked a bunch with .tiff files in the past. The tiff format is more of a container format than a image compression format. It permits lots of weird formats and extensions and its a pretty popular format in science for that reason. I'm not usually a fan of adding dependencies speculatively, but I would make an exception for tiffs. It would be good to add a comment explaining why it's in there.

AddisonSchiller commented 7 years ago

Did some more research. It looks like libtiff5 comes default in Jessie. I read some things about the correct version of libtiff not being used. It shouldn't hurt to install python-libtiff and let pillow go crazy with it. So adding that to the PR as suggested.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+1.8%) to 69.816% when pulling f0b596ab903cc69bb199510990604ef0717435e6 on AddisonSchiller:feature/multipage-tif into 8bb2dd4d35f8c1d89a72fc8b9e09db317f3497f3 on CenterForOpenScience:develop.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+1.8%) to 69.816% when pulling a52a515fb52c8dd75a97ae1be0d3a401bdf68291 on AddisonSchiller:feature/multipage-tif into 8bb2dd4d35f8c1d89a72fc8b9e09db317f3497f3 on CenterForOpenScience:develop.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+1.7%) to 69.72% when pulling d254a1d1dea64ce32c80ea6d0d320ed19d00a321 on AddisonSchiller:feature/multipage-tif into 8bb2dd4d35f8c1d89a72fc8b9e09db317f3497f3 on CenterForOpenScience:develop.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+1.8%) to 69.865% when pulling e05c0fafeef5ed0effbc050ff43568ad22b2ff91 on AddisonSchiller:feature/multipage-tif into 8bb2dd4d35f8c1d89a72fc8b9e09db317f3497f3 on CenterForOpenScience:develop.

coveralls commented 7 years ago

Coverage Status

Coverage increased (+1.8%) to 69.865% when pulling e05c0fafeef5ed0effbc050ff43568ad22b2ff91 on AddisonSchiller:feature/multipage-tif into 8bb2dd4d35f8c1d89a72fc8b9e09db317f3497f3 on CenterForOpenScience:develop.

AddisonSchiller commented 7 years ago

Latest additions: Confirmed (with @felliott ) that libtiff5-dev is working in the docker container Added libtiff5-dev to the docker-file Removed unused python libtiff thing

Turning on libtiff use in pillow fixed color issues on some tiffs fixed resizing on large multipage tiffs (should now display all pages) lots of refactoring/changes from first few versions. Pillow is upgraded to 4.3.0 on this ticket. Standalone it will work with tiffs, but will break the image renderer. There is another ticket I have out that should be merged before this one that will fix what pillow 4.3.0 breaks in MFR.

Changed resampling function on resizing (one used by imageexporter was corrupting some pages of resized pdfs)

Also rewrote QA notes to remove mentions to old broken features. Things should just work now without complications (fingers crossed)

felliott commented 7 years ago

TerTIFFic! Moving to RTM