Giter Club home page Giter Club logo

tiff.js's Introduction

tiff.js

tiff.js is a port of the LibTIFF by compiling the LibTIFF C code with Emscripten.

Demo

Usage

Browser

Download tiff.min.js and load the script by yourself:

var xhr = new XMLHttpRequest();
xhr.responseType = 'arraybuffer';
xhr.open('GET', "url/of/a/tiff/image/file.tiff");
xhr.onload = function (e) {
  var tiff = new Tiff({buffer: xhr.response});
  var canvas = tiff.toCanvas();
  document.body.append(canvas);
};
xhr.send();

Node.js

$ npm install tiff.js

Example

// Usage: node this-file.js input.tiff
var Tiff = require('tiff.js');
var fs = require('fs');

var filename = process.argv[2];
var input = fs.readFileSync(filename);
var image = new Tiff({ buffer: input });
console.log(filename + ': width = ' + image.width() + ', height = ' + image.height());

API

see tiff.d.ts

Note

  • This library does not support JPEG-based compressed TIFF files
  • When you load large tiff file, you will see the error message "Cannot enlarge memory arrays in asm.js"
    • in such case, please call 'Tiff.initialize({TOTAL_MEMORY: ... })' before you create a Tiff instance
  • This JavaScript library uses only some parts of the LibTIFF features
    • To be more precise, I use following functions only
    • TIFFOpen, TIFFClose, TIFFGetField, TIFFReadRGBAImage, TIFFSetDirectory, TIFFCurrentDirectory, TIFFReadDirectory

Alternatives

License

The LibTIFF is LibTIFF Software License, zlib and additional code are zlib License.

tiff.js's People

Contributors

seikichi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tiff.js's Issues

Aw, Snap ( Browser crash )

Hello i'm trying to display tiff image in browser for the user preview on upload when i try to upload small file it works fine but when i tried to upload a large image (340 MB) then the browser get crash and the following message shows up
browser crash

my code is :
image

Thanks In advance.

Does not compile with emcc 1.38.19

I was trying to compile the project by my own because I wanted to add TIFFReadScanline to the exports. When I tried, I saw that the 1.2.8 version of zlib was no longer available to download on the server, so I updated it to 1.2.11. After that the libjpeg emconfigure ./configure printed an error:

checking dynamic linker characteristics... ERROR:root:no input files
note that input files without a known suffix are ignored, make sure your input files end with one of: ('.c', '.C', '.i', '.cpp', '.cxx', '.cc',
'.c++', '.CPP', '.CXX', '.CC', '.C++', '.ii', '.m', '.mi', '.mm', '.mii', '/dev/null', '.bc', '.o', '.obj', '.lo', '.dylib', '.so', '.a', '.ll', '.h', '.hxx', '.hpp', '.hh', '.H', '.HXX', '.HPP', '.HH')
GNU/Linux ld.so

I tried to compile it using emconfigure ./configure --disable-shared but it also didn't work.

Which version of emcc did you use to compile this project?

Source too large error

Hi team ,
I am using this library to convert tiff and tif to jpg. So it works fine with small size file upto 10MB but gives errror such has source too large when to deal with big files . So required help.

Demo attempts to load jquery over HTTP when loaded over HTTPS

When attempting to view the demo via HTTPS in chrome, it fails to load due to jquery being requested over HTTP.

Error in console: (Chrome)

Mixed Content: The page at 'https://seikichi.github.io/tiff.js/basic.html' was loaded over HTTPS, but requested an insecure script 'http://code.jquery.com/jquery-1.10.1.min.js'. This request has been blocked; the content must be served over HTTPS.

This can be corrected by using protocol relative URLs or by always using an HTTPS version of jquery.

include tiff.d.ts to package file list

Currently, there is a tiff.d.ts file in the project that is not included in the files section of the package.json therefore, the typings can't be used in TypeScript projects.

"tsc" command?

The file build.sh has this command line:

 tsc emscripten.d.ts tiff_tag.ts tiff_api.ts -d

My environment (Gentoo) does not recognize "tsc". Moreover, I could not find any reference to "tsc" in the emscripten project. What does this command represent?

alternative to tiff.js

Hi guys,

I am developing Photopea editor and I needed a client-side TIFF parser.

Since tiff.js is 1.5 MB, I made my own TIFF parser UTIF.js, which is just 17 kB and has almost the same capabilities. If you want to extend it or play around, you don't need Emscripten or any other native apps.

Can't get buildscript working

I'm stuck on the configure command for Tiff-4.0.6 part of the build.sh

I get the error

checking for inflateEnd in -lz... no
configure: error: Zlib library not found at /mnt/c/DMDevelopment/HTML5/tiff.js/zlib-1.2.11/
ERROR root: Configure step failed with non-zero return code 1! Command line: ['./configure', '--with-zlib-include-dir=/mnt/c/DMDevelopment/HTML5/tiff.js/zlib-1.2.11/', '--with-zlib-lib-dir=/mnt/c/DMDevelopment/HTML5/tiff.js/zlib-1.2.11/', '--with-jpeg-include-dir=/mnt/c/DMDevelopment/HTML5/tiff.js/jpeg-9b/', '--with-jpeg-lib-dir=/mnt/c/DMDevelopment/HTML5/tiff.js/jpeg-9b/.libs/', '--enable-shared']

Thanks for any help,

p.s. I fixed the 600 dpi image issue but need to be able to build the project.

TIFFFetchNormalTag: Warning console log's

I keep getting these console log warnings. Is there a way to turn them off or somehow fix them after the tif file exists?

TIFFFetchNormalTag: Warning, ASCII value for tag "DocumentName" contains null byte in value; value incorrectly truncated during reading due to implementation limitations.
TIFFFetchNormalTag: Warning, ASCII value for tag "ImageDescription" contains null byte in value; value incorrectly truncated during reading due to implementation limitations.

PS - THANK YOU for this.

tiff.getField(278) - ROWSPERSTRIP incorrect for larger values?

I am using tiff.getField(278) to get the TIFF TAG ROWSPERSTRIP for smaller values probably less than 127 it seems to return the correct value of ROWSPERSTRIP. However with TIFF files whose ROWSPERSTRIP values are greater than some number say 200 the value returned is incorrect. I tried a couple of TIFF files whose ROWSPERSTRIP value is 224 and 768 as reported by AsTiffTagViewer but tiff.js returns my call to tiff.getField(278) on this 2 files incorrectly as 6 and 1 respectively.

Links to 2 files that should report ROWSPERSTRIP as 224 according to AsTiffTagViewer but but tiff.js tiff.getField(278) reports them as 6:

https://onedrive.live.com/redir?resid=af5a9ece0b308510!26835&authkey=!ACmtxSRgPjSDmBQ&ithint=file%2ctif

https://onedrive.live.com/redir?resid=af5a9ece0b308510!26836&authkey=!AFfs8go896rwFnU&ithint=file%2ctif

Link to 2 file that tiff.js tiff.getField(278) reports the ROWSPERSTRIP correctly:

https://onedrive.live.com/redir?resid=af5a9ece0b308510!26839&authkey=!ANff_QTWIWrk7Nw&v=3&ithint=photo%2ctif

https://onedrive.live.com/redir?resid=af5a9ece0b308510!26838&authkey=!AAAfWoAdqFvIGWs&v=3&ithint=photo%2ctif

Neal Davis

Automatic Flip vertical image

It is great library. Only found one issue in that library. Getting mirror image or flipped image if we load vertical image.

display local file

Can you display a TIFF from a dataTransfer object (e.g. from a drag & drop)?

Cannot enlarge memory arrays in asm.js. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216, or (2) set Module.TOTAL_MEMORY before the program runs.

I am testing your project and sometimes it gives me an error like this 'Cannot enlarge memory arrays in asm.js. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216, or (2) set Module.TOTAL_MEMORY before the program runs.'
how can I solve this problem? This happens when I display many tiff images. I hope you can answer my question as soon as possible. Thank you in advance.

Out of memory at ImageData creation

I am showing tiff image using tiff.js, But sometimes i am getting this error.

error RangeError: Failed to execute 'createImageData' on 'CanvasRenderingContext2D': Out of memory at ImageData creation
at Lb.toCanvas (tiff.min.js:3186)

image

$(function () {
$('.modal-body').html("");
Tiff.initialize({TOTAL_MEMORY: 16777216 * 10});
var xhr = new XMLHttpRequest();
xhr.open('GET', 'doc/'+filename);
xhr.responseType = 'arraybuffer';
xhr.onload = function (e) {
var buffer = xhr.response;
var tiff = new Tiff({buffer: buffer});
console.log('tiff',tiff);
console.log('tiff.countDirectory()',tiff.countDirectory());
for (var i = 0, len = tiff.countDirectory(); i < len; ++i) {
try{
console.log('i',i);
tiff.setDirectory(i);
var canvas = tiff.toCanvas();
console.log('canvas',canvas);
$('.modal-body').append(canvas);
console.log('filename',filename);
$('.modal-title').text(filename);
$('#exampleModalLong').modal('show');
}catch(e){
console.log('error',e);
}
}
};
xhr.onloadend = function() {
console.log('xhr',xhr);
if(xhr.status == 404) {
console.log(' replied 404');
document.getElementById('next').click();
}
}
xhr.send();
});

Cannot resolve module 'fs'

I am using webpack to built a bundle that has tiff.js. I have not installed fs as I plan to use in browser however I see the following warning / error:

ERROR in ./~/tiff.js/tiff.min.js
Module not found: Error: Cannot resolve module 'fs' in /Users/alex/git/project/node_modules/tiff.js
 @ ./~/tiff.js/tiff.min.js 103:7-20 1056:331-344

[Question] Recommended TIFF reader

Hi, this library looks great.
As it predates WASM, I'm curious if you would recommend this as a performant modern library to read TIFFs (with multi-page support)? Or, if there are alternatives you would favor? (I'm a noob to JS and image decoding in general)
Thanks!

firefox problem

Hi everyone,

I am currently using tiff.js in a web application project and everything was fine until I tried to display in my browser Tiff pictures. I am getting tiff pictures from a websocket connection and I am trying to display each picture in the browser one by one after converting it to a blob and then as a arraybuffer.

The problem is that the memory increase steadily without stopping (more than 2GB of ram if i don't stop the app). I think that the garbage collector is not collecting the different arrayBuffer created by tiff.js but I don't understand why.
Changing the memory allocation with Tiff.initialize doesn't change anything.
here is my code:

  reader.onload = function () {
		Tiff.initialize({TOTAL_MEMORY:100100100)};
                let image = new Tiff({ buffer: reader.result });
                let canvas=image.toCanvas();
		canvas.setAttribute('id','canvasStream');		
  };

Edit: I added the manipulation of DOM element so you can see more precisely how I deal with it.

So my question is, is it possible to use tiff.js for converting tiff image to canvas every seconds ? Is there a way to dereference the tiff object, so that the garbage collector will sweep it.
I am using firefox.

Thanks in advance

How to render multipage tiff file

hello,

well i know issues mean the issue and bug the code has, but i can't find any specific place to ask my question,

I'm in very deep need to render each page of a tiff file individually but there is no sample code that i can use... how can i do that?

thank you.

Run Time Fail: assert(sizeof(uint64)==8);

I tried to compile my own version after setting up emscripten on my Gentoo Linux (64) machine. There were warnings issued during the compile documented in another ticket filed shortly before this one. Otherwise, the file built without incident except that the last step of using clojure failed as I do not have closure installed. My understanding is clojure simply compresses and obfuscates the JavaScript, there is no material change. Basically I modified the this project's file basic.html to reference my JavaScript (not compressed).

When I try to load a sample page I receive in my Firefox browser with Firebug Tools activated:

uncaught exception: Assertion failed: sizeof(uint64)==8, at: tif_open.c,99,
TIFFClientOpen at jsStackTrace@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:1062:7 
stackTrace@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:1079:3 
___assert_fail@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:4145:146 
_TIFFClientOpen@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:31018:2 
_TIFFOpen@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:33658:3 
loadModule/asm._TIFFOpen@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:68363:3 
ccallFunc@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:574:9 
Tiff@file:///D:/work/EP/TIFF/tiff_js/tiff_jlpoole.js:70517:104 
loadImage/xhr.onload@file:///D:/work/EP/TIFF/tiff_js/basic_jlpoole.html:32:25

tiff_open.c around line 99 has:

/* The following are configuration checks. They should be redundant, but should not
     * compile to any actual code in an optimised release build anyway. If any of them
     * fail, (makefile-based or other) configuration is not correct */
    assert(sizeof(uint8)==1);
    assert(sizeof(int8)==1);
    assert(sizeof(uint16)==2);
    assert(sizeof(int16)==2);
    assert(sizeof(uint32)==4);
    assert(sizeof(int32)==4);
    assert(sizeof(uint64)==8);
    assert(sizeof(int64)==8);

The system I compiled on is a 64 bit system:

jlpoole@themis ~/work/tiff/tiff.js/trunk/tiff-4.0.3 $ uname -a
Linux themis 3.12.13-gentoo #1 SMP Thu Apr 10 15:16:31 PDT 2014 x86_64 Intel(R) Core(TM) i5 CPU M 460 @ 2.53GHz GenuineIntel GNU/Linux
jlpoole@themis ~/work/tiff/tiff.js/trunk/tiff-4.0.3 $

add TIFFReadScanline method?

Dear seikichi,

I was looking around for a client-side tiff parser for a long time, and so far tiff.js is best in terms of speed and compatibility (e.g., compression methods).

However, I deal with 16bit grayvalue data and I need to get the data without reducing its accuracy. tiff.js does load 16bit gray-images and render them using TIFFReadRGBAimage. Yet, there, the pixel values are rescaled to 8bit per pixel and then set to R, G, and B channel.

To access the real 16bit data, I believe one would need the LibTiff Method TIFFReadScanline, to read a single line to an arraybuffer.

Is this a big deal for you to do?

Looking forward to your answer,
Joe.

Missing Dependencies

When I tried to compile, I received an error message:

WARNING  root: emcc: cannot find library "SM"
WARNING  root: emcc: cannot find library "ICE"
WARNING  root: emcc: cannot find library "Xi"
WARNING  root: emcc: cannot find library "z"
WARNING  root: emcc: cannot find library "m"
WARNING  root: ignoring dynamic library libtiff.so because not compiling to JS or HTML, remember to link it when compiling to JS or HTML at the end
make[1]: Leaving directory `/home/jlpoole/work/tiff/tiff.js/trunk/tiff-4.0.3/tools'

I believe these warning represent dependencies not explicitly stated for this project. See emscripten-core/emscripten#2853 I was told in the referenced issue 2853 that the "m" libraries will already be present in the run environment and that their absence during linking is not a fatal issue.

Although I compiled JavaScript without other errors, it doesn't work whereas the JavaScript checked into this project does. It is my guess the lack of libraries above is the culprit.

What are the additional libraries that need to be built with emscripten?

Tiff.initialize({TOTAL_MEMORY: ... })

how is this set? how is a valid value established? i need to load large scanned tiff files.

i found something like this on stack exchange
Tiff.initialize({TOTAL_MEMORY: 2869796 * 10});
'10' above is a multiplier?

but the example here is like
Tiff.initialize({TOTAL_MEMORY: 5000000});

Mouse...

I require mouseevent or positioning system over the tiff file, as i need to send a feedback, to process that part of image, adding some stamp on it... is there a way?

i use this on angular, but positioning isn't right...
look for /////////// HERE ///////////

app.directive('tiffViewer', [
    function () {
        return {
            restrict: "A",
            scope:{
                onClick: "&"
            },
            link: function (scope, elem, attrs) {

                //function resizeCanvas(htmlCanvas) {
                //    htmlCanvas.width = elem.innerWidth();
                //    htmlCanvas.height = elem.innerHeight();
                //}

                reload();

                function reload() {
                    var src = attrs.src;
                    src += "?ver=" + Date.now();
                    var xhr = new XMLHttpRequest();
                    xhr.responseType = "arraybuffer";
                    xhr.open("GET", src);
                    xhr.onload = function (e) {

                        var parentWidth = elem[0].clientWidth;;
                        var parentHeight = elem[0].clientHeight;

                        Tiff.initialize({ TOTAL_MEMORY: 134217728 });//Need More Memory Once Switching To Big Files
                        var tiff = new Tiff({ buffer: xhr.response});
                        var originalCanvas = tiff.toCanvas();

                        var resizedCanvas = document.createElement("canvas");
                        var resizedContext = resizedCanvas.getContext("2d");
                        resizedCanvas.width = parentWidth; 
                        resizedCanvas.height = parentHeight;

                        resizedContext.drawImage(originalCanvas, 0, 0, parentWidth, parentHeight);
                        //var myResizedData = resizedCanvas.toDataURL(); --> img src

                        //resizeCanvas(canvas);
                        //document.body.append(canvas);
                        elem.empty();
                        elem.append(resizedCanvas);

                        function getCursorPosition(canvas, event) {
                            var rect = canvas.getBoundingClientRect();
                            var x = event.clientX - rect.left;
                            var y = event.clientY - rect.top;
                            //console.log("x: " + x + " y: " + y);
                            return { x, y };
                        }
                                          /////////// HERE ///////////
                        var angCanvas = angular.element(resizedCanvas);
                        angCanvas.on("mousedown",
                            function(evt) {
                                var locLeft = angCanvas.offset().left;
                                var locTop = angCanvas.offset().top;
                                var locRight = angCanvas.offset().right;
                                var locBottom = angCanvas.offset().bottom;
                                var width = angCanvas.innerWidth();
                                var height = angCanvas.innerHeight();
                                var mouseX = getCursorPosition(angCanvas[0], evt).x;
                                var mouseY = getCursorPosition(angCanvas[0], evt).y;

                                if (scope.onClick)
                                    scope.onClick({ data : {locLeft, locTop, locRight, locBottom, width, height, mouseX, mouseY }});
                                //angCanvas.attr("data-width", resizedContext.width);

                            });
                        tiff.close();
                    };
                    xhr.send();
                }; //On Initialize

                attrs.$observe("src", function () {
                    reload();
                }); //On Data Change

                //On Refresh Broadcast
                var refreshMessage = attrs.dataRefreshMessage || attrs.refreshMessage;
                if (refreshMessage) {
                    scope.$on(refreshMessage, function (event, args) {
                        reload();
                    });
                }

            }
        }
    }
]);

RAW Camera Formats?

Hi, I'm developing a photo app. I was wondering about the following ways in which I could use this library:

  1. Can I load RAW formats from cameras such as .ARW files?
  2. If so, how would I proceed to do so?
  3. Are you aware of any resources that I can use to expand this library to use said RAW formats if this library does not natively have the features built in required to do so?

Error in tiff.d.ts during ng build

I am struggling to setup tiff.js with Angular. Anyone has step by step guide on how to setup tiff.js in Angular?

Here is the build error.
ERROR in src/tiff.d.ts:2:69 - error TS2552: Cannot find name 'Module'. Did you mean 'module'?

2 declare var loadModule: (options: Tiff.InitializeOptions) => typeof Module;
~~~~~~

src/tiff.d.ts:39:13
39 declare var module: any;
~~~~~~
'module' is declared here.

Using it with Base64 string

Hi,

I am getting base64 Tiff string from database. How can I use it with the string.

I tried following

var tiff = new Tiff({ buffer: data.content });
but getting this error
1.tiff: Cannot read TIFF header.

Thanks
Imran

publish to npm (or other package manager?)

I couldn't find it on npm, but was wondering if it might be possible to have this published on npm? I think there's a fork of this repo published on bower, but it doesn't appear to have any of the more recent updates.

i get an error like 'Uncaught abort({})'

when i open a 20M tiff file, it failed
Uncaught abort({}) at Error
at jsStackTrace (https://d62epjyi40fiq.cloudfront.net/cm/js/tiff.js:79:20924)
at stackTrace (https://d62epjyi40fiq.cloudfront.net/cm/js/tiff.js:79:21107)
at abort (https://d62epjyi40fiq.cloudfront.net/cm/js/tiff.js๐Ÿ’ฏ5646)
at ___syscall192 (https://d62epjyi40fiq.cloudfront.net/cm/js/tiff.js:79:528423)
at cq (https://d62epjyi40fiq.cloudfront.net/cm/js/tiff.js:89:65708)
at Array.xe (https://d62epjyi40fiq.cloudfront.net/cm/js/tiff.js:83:118776)
at pd (https://d62epjyi40fiq.cloudfront.net/cm/js/tiff.js:83:93033)
at le (https://d62epjyi40fiq.cloudfront.net/cm/js/tiff.js:83:117061)
at Object.ccallFunc [as ccall] (https://d62epjyi40fiq.cloudfront.net/cm/js/tiff.js:79:8204)
at new Tiff (https://d62epjyi40fiq.cloudfront.net/cm/js/tiff.js:301:37)
If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.

before this ,there are 2 warns like this:

RangeError: Source is too large
at Uint8Array.set ()
at Object.mmap (tiff.js:79)
at Object.mmap (tiff.js:79)
at ___syscall192 (tiff.js:79)
at cq (tiff.js:89)
at Array.xe (tiff.js:83)
at pd (tiff.js:83)
at le (tiff.js:83)
at Object.ccallFunc [as ccall] (tiff.js:79)
at new Tiff (tiff.js:301)

can you help me?@seikichi
ps: i use chrome 66.0.3359.117

Build Attempt: 'tiffio.h' file not found

I installed the emscripten according to http://kripken.github.io/emscripten-site/docs/building_from_source/building_emscripten_from_source_on_linux.html

I installed this project at /home/jlpoole/work/tiff.

In directory /home/jlpoole/work/tiff/tiff.js/trunk, I ran:

./build.sh

got:

  ...

Libtiff is now configured for x86_64-unknown-linux-gnu

Installation directory:             /usr/local
Documentation directory:            ${prefix}/share/doc/tiff-4.0.3
C compiler:                         /usr/local/src/emscriptenSDK/emscripten/emcc  -Wall -W
C++ compiler:                       /usr/local/src/emscriptenSDK/emscripten/em++ -g -O2
Enable runtime linker paths:        no
Enable linker symbol versioning:    no
Support Microsoft Document Imaging: yes
Use win32 IO:                       no

Support for internal codecs:
CCITT Group 3 & 4 algorithms: yes
Macintosh PackBits algorithm: yes
LZW algorithm: yes
ThunderScan 4-bit RLE algorithm: yes
NeXT 2-bit RLE algorithm: yes
LogLuv high dynamic range encoding: yes

Support for external codecs:
ZLIB support: no
Pixar log-format algorithm: no
JPEG support: no
Old JPEG support: no
JPEG 8/12 bit dual mode: no
ISO JBIG support: no
LZMA2 support: no

C++ support:                        yes

OpenGL support:                     yes

Making all in port
...

export.c:1:10: fatal error: 'tiffio.h' file not found

include "tiffio.h"

    ^

1 error generated.
ERROR root: compiler frontend failed to generate LLVM bitcode, halting

Yet, tiffio.h is present:

jlpoole@themis ~/work/tiff/tiff.js/trunk $ find . -name "tiffio.h"
./tiff-4.0.3/libtiff/tiffio.h
jlpoole@themis ~/work/tiff/tiff.js/trunk $

IE 11 - Memory Leak

I have memory issue while converting multipage tiff file

var Tiff = new Tiff({buffer: data});
for (var i = 0, len = Tiff.countDirectory(); i < len; ++i)
{
Tiff.setDirectory(i);
var Canvas = Tiff.toCanvas();
}
each time the Tiff.toCanvas(); it takes around 2 sec. Also I have initialized memory so I am getting out of memory issue in IE browser.

Improve performance

Has someone worked on the performance aspect of this API? I really like what has been done and it would be great if the performance can be improved. Currently it takes an average of 1.5s on the Tiff.prototype.toCanvas call. My page contains 100s of tiff images and it would be nice if it could load in a few milliseconds.

Cannot enlarge memory arrays in asm.js

I was trying to load 100 images with dimension 1700 px X 2100 px in parallel, got this issue:

Error Message:โ€ Cannot enlarge memory arrays in asm.js. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 167772160, or (2) set Module.TOTAL_MEMORY before the program runs.โ€

browser: Firefox 34

Please guide us.

Can't view tiff scanned at 600 dpi

I was testing the tiff.js in a React component I had, and I realized that I can't view tiffs scanned 600 dpi on an iPad or iPhone. Console has the warning "Canvas area exceeds the maximum limit (width * height > 16777216)."
My best guess is that the issue is because the tiff was scanned at 600 dpi from an A4-size page, making the canvas area 600 * 8.5 * 600 * 11, which is indeed greater than 16777216. This works properly on my desktop browsers, but not on iPad or iPhone.

Revision to build.sh

I modified build.sh to prevent multiple downloads of archives already present:

# build zlib
if [ ! -e zlib-${ZLIB_PKGVER}.tar.gz ]
then 
    wget http://zlib.net/current/zlib-${ZLIB_PKGVER}.tar.gz
    tar xf zlib-${ZLIB_PKGVER}.tar.gz
fi

cd zlib-${ZLIB_PKGVER}
emconfigure ./configure
emmake make
cd ..


# build libtiff
if [ ! -e tiff-${LIBTIFF_PKGVER}.tar.gz ]
then
    wget http://download.osgeo.org/libtiff/tiff-${LIBTIFF_PKGVER}.tar.gz
    tar xzvf tiff-${LIBTIFF_PKGVER}.tar.gz
fi

cd tiff-${LIBTIFF_PKGVER}

...

countDirectory decrementing

I have the following code to iterate through the tiff pages:

       function displayTiff(index)
        {
            if (tiff)
            {
                if (index >= 0 && index < tiff.countDirectory())
                {
                    tiff.setDirectory(index);

                    var canvas = tiff.toCanvas();

                    if (canvas)
                    {
                        canvas.setAttribute('style', 'width: 4.25in;'); 
                    }

                    canvas.addEventListener('mouseout', function(e) {
                        $('#mouseCoodinates').text('');
                    }, false);

                    canvas.addEventListener('mousemove', function(e) {

                        $('#mouseCoodinates').text('x=' + e.x + ';y=' + e.y);

                        // zoomImage(e.x, e.y);
                    }, false);
                    
                    $('#tiffDiv canvas').remove();
                    
                    $('#tiffDiv').append(canvas);
                }
            }
        }

I could never page to the end of the tiff -- I usually stopped around page 5 even though I new my TIFF had more pages. I put in a watch and saw that countDirectory() was decrementing. I expected if the TIFF had 8 pages it would always be 8, but by the time I reached the fifth page, countDirectory() was returning 5 and I couldn't page further. I changed my code to capture the value of countDirectory() immediately after loading the tiff and then used that value as my max and the code works, but I wanted to let you know this might be an issue (maybe I don't understand how "countDirectory()" is supposed to work.)

Thank you for a great product, though!

UINT16 image support

how to get the raw 16 bit luminance data buffer from tiff object ?

Good day sir:
My trouble is about tiff format that be transformed by the function tiff.toCanvas.
The type of my tiff image is 16 bit grayscale, which the color format is luminance.
I defined a tiff object from a buffer like this :
var tiff = new Tiff({buffer: result.target.result});
var canvasTiff = tiff.toCanvas();
When I called tiff.toCanvas() function , I found the type of the tiff data which should be 16 bit grayscale was transformed to 8bit *4 RGBA type.
I don't know how to turn it back to 16 bit luminance;

Can you help me to get the raw image data buffer from the tiff object?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.