Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Deps #35

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions UTIF.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ var UTIF = {};
if (typeof module == "object") {module.exports = UTIF;}
else {self.UTIF = UTIF;}

var pako, JpegDecoder;
if (typeof require == "function") {pako = require("pako"); JpegDecoder = require("jpgjs").JpegDecoder;}
else {pako = self.pako; JpegDecoder = self.JpegDecoder;}
var zlib, JpegDecoder;
if (typeof require == "function") {zlib = require("zlib"); JpegDecoder = require("jpeg-js");}
else {zlib = self.zlib; JpegDecoder = self.JpegDecoder;}

function log() { if (typeof process=="undefined" || process.env.NODE_ENV=="development") console.log.apply(console, arguments); }

(function(UTIF, pako, JpegDecoder){
(function(UTIF, zlib, JpegDecoder){

UTIF.encodeImage = function(rgba, w, h, metadata)
{
Expand Down Expand Up @@ -131,7 +131,7 @@ UTIF.decode._decompress = function(img, data, off, len, cmpr, tgt, toff, fo) //
else if(cmpr==5) UTIF.decode._decodeLZW(data, off, tgt, toff);
else if(cmpr==6) UTIF.decode._decodeOldJPEG(img, data, off, len, tgt, toff);
else if(cmpr==7) UTIF.decode._decodeNewJPEG(img, data, off, len, tgt, toff);
else if(cmpr==8) { var src = new Uint8Array(data.buffer,off,len); var bin = pako["inflate"](src); for(var i=0; i<bin.length; i++) tgt[toff+i]=bin[i]; }
else if(cmpr==8) { var src = new Uint8Array(data.buffer,off,len); var bin = zlib["inflate"](src); for(var i=0; i<bin.length; i++) tgt[toff+i]=bin[i]; }
else if(cmpr==32773) UTIF.decode._decodePackBits(data, off, len, tgt, toff);
else if(cmpr==32809) UTIF.decode._decodeThunder (data, off, len, tgt, toff);
//else if(cmpr==34713) UTIF.decode._decodeNikon (data, off, len, tgt, toff);
Expand Down Expand Up @@ -183,7 +183,7 @@ UTIF.decode._decodeNikon = function(data, off, len, tgt, toff)

UTIF.decode._decodeNewJPEG = function(img, data, off, len, tgt, toff)
{
if (typeof JpegDecoder=="undefined") { log("jpg.js required for handling JPEG compressed images"); return; }
if (typeof JpegDecoder=="undefined") { log("jpeg-js required for handling JPEG compressed images"); return; }

var tables = img["t347"], tlen = tables ? tables.length : 0, buff = new Uint8Array(tlen + len);

Expand Down Expand Up @@ -220,8 +220,7 @@ UTIF.decode._decodeNewJPEG = function(img, data, off, len, tgt, toff)
}
else
{
var parser = new JpegDecoder(); parser.parse(buff);
var decoded = parser.getData(parser.width, parser.height);
var decoded = JpegDecoder.decode(buff).data;
for (var i=0; i<decoded.length; i++) tgt[toff + i] = decoded[i];
}

Expand Down Expand Up @@ -415,8 +414,7 @@ UTIF.decode._decodeOldJPEG = function(img, data, off, len, tgt, toff)
buff[bufoff++] = 255; buff[bufoff++] = EOI;
}

var parser = new JpegDecoder(); parser.parse(buff);
var decoded = parser.getData(parser.width, parser.height);
var decoded = JpegDecoder.decode(buff);
for (var i=0; i<decoded.length; i++) tgt[toff + i] = decoded[i];

// PhotometricInterpretation is 6 (YCbCr) for JPEG, but after decoding we populate data in
Expand Down Expand Up @@ -907,5 +905,5 @@ UTIF._copyTile = function(tb, tw, th, b, w, h, xoff, yoff)
}
}

})(UTIF, pako, JpegDecoder);
})(UTIF, zlib, JpegDecoder);
})();
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"conversion"
],
"dependencies": {
"jpgjs": "github:makr28/jpgjs",
"pako": "^1.0.5"
"jpeg-js": "^0.3.4"
}
}
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


jpeg-js@^0.3.4:
version "0.3.4"
resolved "https://registry.yarnpkg.com/jpeg-js/-/jpeg-js-0.3.4.tgz#dc2ba501ee3d58b7bb893c5d1fab47294917e7e7"