Socket
Socket
Sign inDemoInstall

utif

Package Overview
Dependencies
1
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 1.2.0

2

package.json
{
"name": "utif",
"description": "Fast and advanced TIFF decoder",
"version": "1.1.2",
"version": "1.2.0",
"homepage": "https://github.com/photopea/UTIF.js",

@@ -6,0 +6,0 @@ "author": "photopea (https://github.com/photopea)",

# UTIF.js
A small, fast and advanced TIFF / EXIF decoder and encoder. It is the main TIFF library for [Photopea image editor](https://www.photopea.com). Try to open your TIFF file with Photopea to see, if UTIF.js can parse it.
A small, fast and advanced TIFF / EXIF (+ DNG and other TIFF-ish files) decoder and encoder. It is the main TIFF library for [Photopea image editor](https://www.photopea.com). Try to open your TIFF file with Photopea to see, if UTIF.js can parse it.

@@ -4,0 +4,0 @@ * Supports Black & White, Grayscale, RGB and Paletted images

@@ -5,2 +5,5 @@

// Allows us to use this inside ServiceWorker
if (typeof window === 'undefined' && typeof self !== 'undefined') window = self;
// Make available for import by `require()`

@@ -78,14 +81,15 @@ if (typeof module == "object") {module.exports = UTIF;}

var img = ifds[ii];
if(img["t256"]==null) continue; // EXIF files don't have TIFF tags
img.isLE = id=="II";
img.width = img["t256"][0]; delete img["t256"];
img.height = img["t257"][0]; delete img["t257"];
img.width = img["t256"][0]; //delete img["t256"];
img.height = img["t257"][0]; //delete img["t257"];
var cmpr = img["t259"][0]; delete img["t259"];
var fo = img["t266"] ? img["t266"][0] : 1; delete img["t266"];
var cmpr = img["t259"][0]; //delete img["t259"];
var fo = img["t266"] ? img["t266"][0] : 1; //delete img["t266"];
if(img["t284"] && img["t284"][0]==2) log("PlanarConriguration 2 should not be used!");
var bipp = (img["t258"]?img["t258"][0]:1) * (img["t277"]?img["t277"][0]:1); // bits per pixel
var bipp = (img["t258"]?Math.min(32,img["t258"][0]):1) * (img["t277"]?img["t277"][0]:1); // bits per pixel
var soff = img["t273"]; if(soff==null) soff = img["t324"];
var bcnt = img["t279"]; if(cmpr==1 && soff.length==1) bcnt = [(img.height*img.width*bipp)>>3]; if(bcnt==null) bcnt = img["t325"];
var bytes = new Uint8Array((img.width*img.height*bipp)>>3), bilen = 0;
var bcnt = img["t279"]; if(cmpr==1 && soff.length==1) bcnt = [(img.height*img.width*bipp)>>>3]; if(bcnt==null) bcnt = img["t325"];
var bytes = new Uint8Array((img.width*img.height*bipp)>>>3), bilen = 0;

@@ -97,3 +101,3 @@ if(img["t322"]!=null) // tiled

var ty = Math.floor((img.height + th - 1) / th);
var tbuff = new Uint8Array(tw*th*bipp>>3);
var tbuff = new Uint8Array((tw*th*bipp)>>>3);
for(var y=0; y<ty; y++)

@@ -104,3 +108,3 @@ for(var x=0; x<tx; x++)

UTIF.decode._decompress(img, data, soff[i], bcnt[i], cmpr, tbuff, 0, fo);
UTIF._copyTile(tbuff, (tw*bipp)>>3, th, bytes, (img.width*bipp)>>3, img.height, (x*tw*bipp)>>3, y*th);
UTIF._copyTile(tbuff, (tw*bipp)>>>3, th, bytes, (img.width*bipp)>>>3, img.height, (x*tw*bipp)>>>3, y*th);
}

@@ -114,3 +118,3 @@ bilen = bytes.length<<3;

{
UTIF.decode._decompress(img, data, soff[i], bcnt[i], cmpr, bytes, bilen>>3, fo);
UTIF.decode._decompress(img, data, soff[i], bcnt[i], cmpr, bytes, bilen>>>3, fo);
bilen += (img.width * bipp * rps);

@@ -120,3 +124,3 @@ }

}
img.data = new Uint8Array(bytes.buffer, 0, bilen>>3);
img.data = new Uint8Array(bytes.buffer, 0, bilen>>>3);
}

@@ -137,2 +141,3 @@ return ifds;

else if(cmpr==32809) UTIF.decode._decodeThunder (data, off, len, tgt, toff);
//else if(cmpr==34713) UTIF.decode._decodeNikon (data, off, len, tgt, toff);
else log("Unknown compression", cmpr);

@@ -150,10 +155,38 @@

UTIF.decode._decodeNikon = function(data, off, len, tgt, toff)
{
var nikon_tree = [
[ 0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0, /* 12-bit lossy */
5,4,3,6,2,7,1,0,8,9,11,10,12 ],
[ 0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0, /* 12-bit lossy after split */
0x39,0x5a,0x38,0x27,0x16,5,4,3,2,1,0,11,12,12 ],
[ 0,1,4,2,3,1,2,0,0,0,0,0,0,0,0,0, /* 12-bit lossless */
5,4,6,3,7,2,8,1,9,0,10,11,12 ],
[ 0,1,4,3,1,1,1,1,1,2,0,0,0,0,0,0, /* 14-bit lossy */
5,6,4,7,8,3,9,2,1,0,10,11,12,13,14 ],
[ 0,1,5,1,1,1,1,1,1,1,2,0,0,0,0,0, /* 14-bit lossy after split */
8,0x5c,0x4b,0x3a,0x29,7,6,5,4,3,2,1,0,13,14 ],
[ 0,1,4,2,2,3,1,2,0,0,0,0,0,0,0,0, /* 14-bit lossless */
7,6,8,5,9,4,10,3,11,12,2,0,1,13,14 ] ];
//struct decode *dindex;
var ver0, ver1, vpred, hpred, csize;
var i, min, max, step=0, huff=0, split=0, row, col, len, shl, diff;
console.log(data.slice(off,off+100));
ver0 = data[off]; off++;
ver1 = data[off]; off++;
console.log(ver0.toString(16), ver1.toString(16), len);
}
UTIF.decode._decodeNewJPEG = function(img, data, off, len, tgt, toff)
{
//throw "e";
//console.log("_decodeNewJPEG", off, toff);
if (typeof JpegDecoder=="undefined") { log("jpg.js required for handling JPEG compressed images"); return; }
var SOI = 216, EOI = 217, boff = 0;
var tables = img["t347"], tlen = tables ? tables.length : 0, buff = new Uint8Array(tlen + len);
if (tables) {
var SOI = 216, EOI = 217, boff = 0;
for (var i=0; i<(tlen-1); i++) {

@@ -171,11 +204,28 @@ // Skip EOI marker from JPEGTables

}
for (var i=2; i<len; i++) buff[boff++] = data[off+i];
}
else
for (var i=0; i<len; i++) buff[boff++] = data[off+i];
for (var i=0; i<len; i++) buff[i] = data[off+i];
var parser = new JpegDecoder(); parser.parse(buff);
var decoded = parser.getData(parser.width, parser.height);
for (var i=0; i<decoded.length; i++) tgt[toff + i] = decoded[i];
if(img["t262"]==32803) { // lossless JPEG (used in DNG files) is not available in JpegDecoder.
var bps = img["t258"][0], dcdr = new LosslessJpegDecoder();
var out = dcdr.decode(buff), olen=out.length;
if(false) {}
else if(bps==16) for(var i=0; i<olen; i++) { tgt[toff++] = (out[i]&255); tgt[toff++] = (out[i]>>>8); }
else if(bps==12) {
for(var i=0; i<olen; i+=2) { tgt[toff++] = (out[i]>>>4); tgt[toff++] = ((out[i]<<4)|(out[i+1]>>>8))&255; tgt[toff++] = out[i+1]&255; }
}
else throw "unsupported bit depth "+bps;
}
else {
var parser = new JpegDecoder(); parser.parse(buff);
var decoded = parser.getData(parser.width, parser.height);
for (var i=0; i<decoded.length; i++) tgt[toff + i] = decoded[i];
}
//console.log(out);
//throw "e";
//throw "e";

@@ -201,7 +251,7 @@ // PhotometricInterpretation is 6 (YCbCr) for JPEG, but after decoding we populate data in

while(off<lim) {
var b = data[off], msk = (b>>6), n = (b&63); off++;
if(msk==3) { px=(n&15); tgt[qoff>>1] |= (px<<(4*(1-qoff&1))); qoff++; }
if(msk==0) for(var i=0; i<n; i++) { tgt[qoff>>1] |= (px<<(4*(1-qoff&1))); qoff++; }
if(msk==2) for(var i=0; i<2; i++) { var d=(n>>(3*(1-i)))&7; if(d!=4) { px+=d3[d]; tgt[qoff>>1] |= (px<<(4*(1-qoff&1))); qoff++; } }
if(msk==1) for(var i=0; i<3; i++) { var d=(n>>(2*(2-i)))&3; if(d!=2) { px+=d2[d]; tgt[qoff>>1] |= (px<<(4*(1-qoff&1))); qoff++; } }
var b = data[off], msk = (b>>>6), n = (b&63); off++;
if(msk==3) { px=(n&15); tgt[qoff>>>1] |= (px<<(4*(1-qoff&1))); qoff++; }
if(msk==0) for(var i=0; i<n; i++) { tgt[qoff>>>1] |= (px<<(4*(1-qoff&1))); qoff++; }
if(msk==2) for(var i=0; i<2; i++) { var d=(n>>>(3*(1-i)))&7; if(d!=4) { px+=d3[d]; tgt[qoff>>>1] |= (px<<(4*(1-qoff&1))); qoff++; } }
if(msk==1) for(var i=0; i<3; i++) { var d=(n>>>(2*(2-i)))&3; if(d!=2) { px+=d2[d]; tgt[qoff>>>1] |= (px<<(4*(1-qoff&1))); qoff++; } }
}

@@ -247,8 +297,8 @@ }

while((boff>>3)<off+slen)
while((boff>>>3)<off+slen)
{
b1 = U._findDiff(pline, a0+(a0==0?0:1), 1-clr), b2 = U._findDiff(pline, b1, clr); // could be precomputed
var bit =0;
if(fo==1) bit = (data[boff>>3]>>(7-(boff&7)))&1;
if(fo==2) bit = (data[boff>>3]>>( (boff&7)))&1;
if(fo==1) bit = (data[boff>>>3]>>>(7-(boff&7)))&1;
if(fo==2) bit = (data[boff>>>3]>>>( (boff&7)))&1;
boff++; wrd+=bit;

@@ -287,8 +337,8 @@ if(mode=="H") {

var y=-1, mode="", toRead=0, is1D=false;
while((boff>>3)<off+slen)
while((boff>>>3)<off+slen)
{
b1 = U._findDiff(pline, a0+(a0==0?0:1), 1-clr), b2 = U._findDiff(pline, b1, clr); // could be precomputed
var bit =0;
if(fo==1) bit = (data[boff>>3]>>(7-(boff&7)))&1;
if(fo==2) bit = (data[boff>>3]>>( (boff&7)))&1;
if(fo==1) bit = (data[boff>>>3]>>>(7-(boff&7)))&1;
if(fo==2) bit = (data[boff>>>3]>>>( (boff&7)))&1;
boff++; wrd+=bit;

@@ -317,4 +367,4 @@

if(y>=0) U._writeBits(line, tgt, toff*8+y*w);
if(fo==1) is1D = ((data[boff>>3]>>(7-(boff&7)))&1)==1;
if(fo==2) is1D = ((data[boff>>3]>>( (boff&7)))&1)==1;
if(fo==1) is1D = ((data[boff>>>3]>>>(7-(boff&7)))&1)==1;
if(fo==2) is1D = ((data[boff>>>3]>>>( (boff&7)))&1)==1;
boff++;

@@ -335,3 +385,3 @@ if(U._decodeG3.allow2D==null) U._decodeG3.allow2D=is1D;

{
for(var i=0; i<bits.length; i++) tgt[(boff+i)>>3] |= (bits[i]<<(7-((boff+i)&7)));
for(var i=0; i<bits.length; i++) tgt[(boff+i)>>>3] |= (bits[i]<<(7-((boff+i)&7)));
}

@@ -385,9 +435,34 @@

269:"DocumentName",270:"ImageDescription",271:"Make",272:"Model",273:"StripOffset",274:"Orientation",277:"SamplesPerPixel",278:"RowsPerStrip",
279:"StripByteCounts",280:"MinSampleValue",281:"MaxSampleValue",282:"XResolution",283:"YResolution",284:"PlanarConfiguration",286:"XPosition",287:"YPosition",
292:"T4Options",296:"ResolutionUnit",297:"PageNumber",305:"Software",306:"DateTime",315:"Artist",317:"Predictor",320:"ColorMap",321:"HalftoneHints",322:"TileWidth",
323:"TileLength",324:"TileOffset",325:"TileByteCounts",336:"DotRange",338:"ExtraSample",339:"SampleFormat", 347:"JPEGTables",
279:"StripByteCounts",280:"MinSampleValue",281:"MaxSampleValue",282:"XResolution",283:"YResolution",284:"PlanarConfiguration",285:"PageName",
286:"XPosition",287:"YPosition",
292:"T4Options",296:"ResolutionUnit",297:"PageNumber",305:"Software",306:"DateTime",315:"Artist",316:"HostComputer",317:"Predictor",320:"ColorMap",
321:"HalftoneHints",322:"TileWidth",
323:"TileLength",324:"TileOffset",325:"TileByteCounts",330:"SubIFDs",336:"DotRange",338:"ExtraSample",339:"SampleFormat", 347:"JPEGTables",
512:"JPEGProc",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",519:"JPEGQTables",520:"JPEGDCTables",521:"JPEGACTables",
529:"YCbCrCoefficients",530:"YCbCrSubSampling",531:"YCbCrPositioning",532:"ReferenceBlackWhite",33432:"Copyright",34377:"Photoshop"};
529:"YCbCrCoefficients",530:"YCbCrSubSampling",531:"YCbCrPositioning",532:"ReferenceBlackWhite",700:"XMP",
33421:"CFARepeatPatternDim",33422:"CFAPattern",33432:"Copyright",33434:"ExposureTime",33437:"FNumber",33723:"IPTC/NAA",34377:"Photoshop",
34665:"ExifIFD",34850:"ExposureProgram",34853:"GPSInfo",34855:"ISOSpeedRatings",34858:"TimeZoneOffset",34859:"SelfTimeMode",
36867:"DateTimeOriginal",36868:"DateTimeDigitized",
37377:"ShutterSpeedValue",37378:"ApertureValue",37380:"ExposureBiasValue",37383:"MeteringMode",37385:"Flash",37386:"FocalLength",
37390:"FocalPlaneXResolution",37391:"FocalPlaneYResolution",37392:"FocalPlaneResolutionUnit",37393:"ImageNumber",37398:"TIFF/EPStandardID",37399:"SensingMethod",
37500:"MakerNote",37510:"UserComment",
40092:"XPComment",40094:"XPKeywords",
40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelXDimension",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",
41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41990:"SceneCaptureType",
50706:"DNGVersion",50707:"DNGBackwardVersion",50708:"UniqueCameraModel",50709:"LocalizedCameraModel",50710:"CFAPlaneColor",
50711:"CFALayout",50712:"LinearizationTable",50713:"BlackLevelRepeatDim",50714:"BlackLevel",50716:"BlackLevelDeltaV",50717:"WhiteLevel",
50718:"DefaultScale",50719:"DefaultCropOrigin",
50720:"DefaultCropSize",50733:"BayerGreenSplit",50738:"AntiAliasStrength",
50721:"ColorMatrix1",50722:"ColorMatrix2",50723:"CameraCalibration1",50724:"CameraCalibration2",50727:"AnalogBalance",50728:"AsShotNeutral",
50730:"BaselineExposure",50731:"BaselineNoise",50732:"BaselineSharpness",50734:"LinearResponseLimit",50735:"CameraSerialNumber",50736:"LensInfo",50739:"ShadowScale",
50740:"DNGPrivateData",50741:"MakerNoteSafety",50778:"CalibrationIlluminant1",50779:"CalibrationIlluminant2",50780:"BestQualityScale",
50781:"RawDataUniqueID",50827:"OriginalRawFileName",50829:"ActiveArea",50830:"MaskedAreas",50931:"CameraCalibrationSignature",50932:"ProfileCalibrationSignature",
50935:"NoiseReductionApplied",50936:"ProfileName",50937:"ProfileHueSatMapDims",50938:"ProfileHueSatMapData1",50939:"ProfileHueSatMapData2",
50940:"ProfileToneCurve",50941:"ProfileEmbedPolicy",50942:"ProfileCopyright",
50964:"ForwardMatrix1",50965:"ForwardMatrix2",50966:"PreviewApplicationName",50967:"PreviewApplicationVersion",50969:"PreviewSettingsDigest",
50970:"PreviewColorSpace",50971:"PreviewDateTime",50972:"RawImageDigest",
51008:"OpcodeList1",51009:"OpcodeList2",51022:"OpcodeList3",51041:"NoiseProfile",51089:"OriginalDefaultFinalSize",
51090:"OriginalBestQualityFinalSize",51091:"OriginalDefaultCropSize",51125:"DefaultUserCrop"};
UTIF.ttypes = { 256:3,257:3,258:3, 259:3, 262:3, 273:4, 274:3, 277:3,278:4,279:4, 282:5, 283:5, 284:3, 286:5,287:5, 296:3, 305:2, 306:2, 338:3, 513:4, 514:4, 34665:4 };
UTIF.ttypes = { 256:3,257:3,258:3, 259:3, 262:3, 273:4, 274:3, 277:3,278:4,279:4, 282:5, 283:5, 284:3, 286:5,287:5, 296:3, 305:2, 306:2, 338:3, 513:4, 514:4, 34665:4 };

@@ -399,2 +474,3 @@ UTIF._readIFD = function(bin, data, offset, ifds)

//console.log(">>>----------------");
for(var i=0; i<cnt; i++) {

@@ -406,11 +482,21 @@ var tag = bin.readUshort(data, offset); offset+=2;

var arr = ifd["t"+tag] = [];
if(type==1 || type==7) { for(var j=0; j<num; j++) arr.push(data[(num<5 ? offset-4 : voff)+j]); }
if(type==2) { arr.push( bin.readASCII(data, (num<5 ? offset-4 : voff), num-1) ); }
if(type==3) { for(var j=0; j<num; j++) arr.push(bin.readUshort(data, (num<3 ? offset-4 : voff)+2*j)); }
if(type==4) { for(var j=0; j<num; j++) arr.push(bin.readUint (data, (num<2 ? offset-4 : voff)+4*j)); }
if(type==5) { for(var j=0; j<num; j++) arr.push(bin.readUint(data, voff+j*8) / bin.readUint(data,voff+j*8+4)); }
if(arr.length==0) log("unknown TIFF tag type: ", type, "num:",num);
//log(tag, type, arr, UTIF.tags[tag]);
var arr = [];
ifd["t"+tag] = arr;
//ifd["t"+tag+"-"+UTIF.tags[tag]] = arr;
if(type== 1 || type==7) { for(var j=0; j<num; j++) arr.push(data[(num<5 ? offset-4 : voff)+j]); }
if(type== 2) { arr.push( bin.readASCII(data, (num<5 ? offset-4 : voff), num-1) ); }
if(type== 3) { for(var j=0; j<num; j++) arr.push(bin.readUshort(data, (num<3 ? offset-4 : voff)+2*j)); }
if(type== 4) { for(var j=0; j<num; j++) arr.push(bin.readUint (data, (num<2 ? offset-4 : voff)+4*j)); }
if(type== 5) { for(var j=0; j<num; j++) arr.push(bin.readUint (data, voff+j*8) / bin.readUint(data,voff+j*8+4)); }
if(type== 8) { for(var j=0; j<num; j++) arr.push(bin.readShort (data, (num<3 ? offset-4 : voff)+2*j)); }
if(type== 9) { for(var j=0; j<num; j++) arr.push(bin.readInt (data, (num<2 ? offset-4 : voff)+4*j)); }
if(type==10) { for(var j=0; j<num; j++) arr.push(bin.readInt (data, voff+j*8) / bin.readInt (data,voff+j*8+4)); }
if(type==11) { for(var j=0; j<num; j++) arr.push(bin.readFloat (data, voff+j*4)); }
if(type==12) { for(var j=0; j<num; j++) arr.push(bin.readDouble(data, voff+j*8)); }
if(num!=0 && arr.length==0) log("unknown TIFF tag type: ", type, "num:",num);
//log(tag, type, UTIF.tags[tag], arr);
if(tag== 330) for(var j=0; j<num; j++) UTIF._readIFD(bin, data, arr[j], ifds);
//if(tag==34665) UTIF._readIFD(bin, data, arr[0], ifds);
}
//console.log("<<<---------------");
return offset;

@@ -453,5 +539,6 @@ }

// 0: WhiteIsZero, 1: BlackIsZero, 2: RGB, 3: Palette color, 4: Transparency mask, 5: CMYK
var intp = out["t262"][0], bps = (out["t258"]?out["t258"][0]:1), isLE = out.isLE ? 1 : 0;
var intp = out["t262"][0], bps = (out["t258"]?Math.min(32,out["t258"][0]):1), isLE = out.isLE ? 1 : 0;
//log("interpretation: ", intp, "bps", bps, out);
if(intp==0) {
if(false) {}
else if(intp==0) {
if(bps== 1) for(var i=0; i<area; i++) { var qi=i<<2, px=((data[i>>3])>>(7- (i&7)))& 1; img[qi]=img[qi+1]=img[qi+2]=( 1-px)*255; img[qi+3]=255; }

@@ -461,3 +548,3 @@ if(bps== 4) for(var i=0; i<area; i++) { var qi=i<<2, px=((data[i>>1])>>(4-4*(i&1)))&15; img[qi]=img[qi+1]=img[qi+2]=(15-px)* 17; img[qi+3]=255; }

}
if(intp==1) {
else if(intp==1) {
if(bps== 1) for(var i=0; i<area; i++) { var qi=i<<2, px=((data[i>>3])>>(7- (i&7)))&1; img[qi]=img[qi+1]=img[qi+2]=(px)*255; img[qi+3]=255; }

@@ -468,3 +555,3 @@ if(bps== 2) for(var i=0; i<area; i++) { var qi=i<<2, px=((data[i>>2])>>(6-2*(i&3)))&3; img[qi]=img[qi+1]=img[qi+2]=(px)* 85; img[qi+3]=255; }

}
if(intp==2) {
else if(intp==2) {
if(bps== 8) { // this needs to be simplified ... how many channels are there???

@@ -484,10 +571,11 @@ if(out["t338"]) {

}
if(intp==3) {
else if(intp==3) {
var map = out["t320"];
for(var i=0; i<area; i++) { var qi=i<<2, mi=data[i]; img[qi]=(map[mi]>>8); img[qi+1]=(map[256+mi]>>8); img[qi+2]=(map[512+mi]>>8); img[qi+3]=255; }
}
if(intp==5) for(var i=0; i<area; i++) {
else if(intp==5) for(var i=0; i<area; i++) {
var qi=i<<2; var C=255-data[qi], M=255-data[qi+1], Y=255-data[qi+2], K=(255-data[qi+3])*(1/255);
img[qi]=Math.round(C*K); img[qi+1]=Math.round(M*K); img[qi+2]=Math.round(Y*K); img[qi+3]=255;
}
else log("Unknown Photometric interpretation: "+intp);
return img;

@@ -525,4 +613,8 @@ }

readUshort : function(buff, p) { return (buff[p]<< 8) | buff[p+1]; },
readUint : function(buff, p) { var a=UTIF._binBE.ui8; a[0]=buff[p+3]; a[1]=buff[p+2]; a[2]=buff[p+1]; a[3]=buff[p]; return UTIF._binBE.ui32[0]; },
readShort : function(buff, p) { var a=UTIF._binBE.ui8; a[0]=buff[p+1]; a[1]=buff[p+0]; return UTIF._binBE. i16[0]; },
readInt : function(buff, p) { var a=UTIF._binBE.ui8; a[0]=buff[p+3]; a[1]=buff[p+2]; a[2]=buff[p+1]; a[3]=buff[p+0]; return UTIF._binBE. i32[0]; },
readUint : function(buff, p) { var a=UTIF._binBE.ui8; a[0]=buff[p+3]; a[1]=buff[p+2]; a[2]=buff[p+1]; a[3]=buff[p+0]; return UTIF._binBE.ui32[0]; },
readASCII : function(buff, p, l) { var s = ""; for(var i=0; i<l; i++) s += String.fromCharCode(buff[p+i]); return s; },
readFloat : function(buff, p) { var a=UTIF._binBE.ui8; for(var i=0;i<4;i++) a[i]=buff[p+3-i]; return UTIF._binBE.fl32[0]; },
readDouble : function(buff, p) { var a=UTIF._binBE.ui8; for(var i=0;i<8;i++) a[i]=buff[p+7-i]; return UTIF._binBE.fl64[0]; },

@@ -533,21 +625,33 @@ writeUshort: function(buff, p, n) { buff[p] = (n>> 8)&255; buff[p+1] = n&255; },

}
UTIF._binBE.ui8 = new Uint8Array(4);
UTIF._binBE.ui32 = new Uint32Array(UTIF._binBE.ui8.buffer);
UTIF._binBE.ui8 = new Uint8Array (8);
UTIF._binBE.i16 = new Int16Array (UTIF._binBE.ui8.buffer);
UTIF._binBE.i32 = new Int32Array (UTIF._binBE.ui8.buffer);
UTIF._binBE.ui32 = new Uint32Array (UTIF._binBE.ui8.buffer);
UTIF._binBE.fl32 = new Float32Array(UTIF._binBE.ui8.buffer);
UTIF._binBE.fl64 = new Float64Array(UTIF._binBE.ui8.buffer);
UTIF._binLE = {
nextZero : UTIF._binBE.nextZero,
readUshort : function(buff, p) { return (buff[p+1]<< 8) | buff[p]; },
readUint : function(buff, p) { return (buff[p+3]<<24) | (buff[p+2]<<16) | (buff[p+1]<< 8) | buff[p]; },
readASCII : UTIF._binBE.readASCII
readShort : function(buff, p) { var a=UTIF._binBE.ui8; a[0]=buff[p+0]; a[1]=buff[p+1]; return UTIF._binBE. i16[0]; },
readInt : function(buff, p) { var a=UTIF._binBE.ui8; a[0]=buff[p+0]; a[1]=buff[p+1]; a[2]=buff[p+2]; a[3]=buff[p+3]; return UTIF._binBE. i32[0]; },
readUint : function(buff, p) { var a=UTIF._binBE.ui8; a[0]=buff[p+0]; a[1]=buff[p+1]; a[2]=buff[p+2]; a[3]=buff[p+3]; return UTIF._binBE.ui32[0]; },
readASCII : UTIF._binBE.readASCII,
readFloat : function(buff, p) { var a=UTIF._binBE.ui8; for(var i=0;i<4;i++) a[i]=buff[p+ i]; return UTIF._binBE.fl32[0]; },
readDouble : function(buff, p) { var a=UTIF._binBE.ui8; for(var i=0;i<8;i++) a[i]=buff[p+ i]; return UTIF._binBE.fl64[0]; }
}
UTIF._copyTile = function(tb, tw, th, b, w, h, xoff, yoff)
{
for(var y=0; y<th; y++)
for(var x=0; x<tw; x++)
{
var tx = xoff+x, ty = yoff+y;
if(tx<w && ty<h) b[ty*w+tx] = tb[y*tw+x];
}
//console.log("copyTile", tw, th, w, h, xoff, yoff);
var xlim = Math.min(tw, w-xoff);
var ylim = Math.min(th, h-yoff);
for(var y=0; y<ylim; y++)
{
var tof = (yoff+y)*w+xoff;
var sof = y*tw;
for(var x=0; x<xlim; x++) b[tof+x] = tb[sof+x];
}
}
})(UTIF, pako);
})();
})();
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc