View a multipage TIFF in Javascript

2019-06-20 05:16发布

问题:

I currently have multi-paged TIFF images and I need to browse them page by page via Javascript.

I have no clue about that. Can you help me? I found some other questions but none seems related to Javascript.

Thank you.

回答1:

I very much doubt JavaScript can help you here: Most browsers can't deal with TIFF images in the first place, let alone multi-page ones.

You will need the help of server-side scripting - like PHP - in combination with a tool like ImageMagick.

I've never tried this myself, but IM's multipage syntax seems to be pretty straightforward:

# extract page 15 from tiff file

convert 'image.tif[15]' image-15.jpg  

note that if your TIFF is in CMYK format, you will need to perform an additional colour space conversion to RGB - Internet Explorer can't deal with CMYK images in any format.



回答2:

I ported the LibTIFF library to Javascript with Emscripten (https://github.com/seikichi/tiff.js). This page (http://seikichi.github.io/tiff.js/multipage.html) is the demo of multipage tiff file.



回答3:

There are plugin that provide those function. Alternatiff is a good example.



回答4:

Update

The original project no longer seems to be maintained (thanks Victoria!), but both tiff.js by GPHelmley and seikichi's libTiff port mentioned in their answer have active forks; see

https://github.com/seikichi/tiff.js/network

and

https://github.com/GPHemsley/tiff-js/network

Original

A new, native JavaScript tiff approach has appeared since the last round of answers: tiff.js, with comments on multi-page tiff support here (apparently added in to pdf.js though I haven't checked it out).

I found that for my case it was easy to hack the tiff.js code to allow loading multipage tiffs really easily, and plan to contribute the hack to the tiff.js repo.



回答5:

If you're ok with a certain plugin technology (namely Silverlight or Moonlight), you can use the free LibTiff .NET library to process and display most kinds of TIFF files client-side.