diff --git a/pom.xml b/pom.xml index 8a410659..1841c289 100644 --- a/pom.xml +++ b/pom.xml @@ -9,51 +9,74 @@ 4.4.0 + 21 - 4.4.11 + ${java.version} + ${java.version} + ${java.version} + UTF-8 + UTF-8 + + 3.5.6 + + + 4.4.11 5.2.5 1.0.6 - 1.4.21 - 7.5.5 - 4.0.0 - 16.02-2.01 - 1.0 - 2.7.7 - 1.4.2 - 5.17.2 + 25.10 + + 3.0.6 + 5.5.13.4 + + 1.4.0 3.0.4 - 0.2.1 + 1.0.0-alpha6 + + 1.5.12 4.11.0-1.5.12 0.3.30-1.5.12 7.1.1-1.5.12 - 5.5.13.4 + + + 16.02-2.01 + 7.5.5 + + + 4.0.0 + 5.17.2 + 1.4.2 + + 5.6 - 25.10 - 1.70 - 1.0.3 4.5.16 - - 1.11.0 3.12.0 + + 3.20.0 + 1.11.0 + + 1.0.3 + 1.0 - ${java.version} - ${java.version} - ${java.version} + + 1.70 - UTF-8 - UTF-8 + + 1.4.21 + 2.7.7 + 0.2.1 server + kkFileView-parent 专注文件在线预览服务 https://github.com/kekingcn/kkFileView @@ -89,5 +112,4 @@ github https://github.com/kekingcn/kkFileView/issues - - + \ No newline at end of file diff --git a/server/pom.xml b/server/pom.xml index 8a650a60..29f4c7b3 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -23,7 +23,7 @@ - + aspose-maven-repository https://repository.aspose.com/repo @@ -34,18 +34,11 @@ - - org.jodconverter - jodconverter-local - ${jodconverter.version} - - - + org.springframework.boot spring-boot-starter-web - org.springframework.boot spring-boot-starter-freemarker @@ -54,9 +47,15 @@ org.springframework.boot spring-boot-starter-actuator - - + + + org.jodconverter + jodconverter-local + ${jodconverter.version} + + + org.apache.poi poi @@ -93,85 +92,13 @@ fr.opensagres.xdocreport.document ${xdocreport.version} - - org.apache.httpcomponents.client5 - httpclient5 + com.aspose + aspose-cad + ${aspose-cad.version} - - - net.sf.sevenzipjbinding - sevenzipjbinding - ${sevenzipjbinding.version} - - - net.sf.sevenzipjbinding - sevenzipjbinding-all-platforms - ${sevenzipjbinding.version} - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.redisson - redisson - ${redisson.version} - - - - - com.googlecode.juniversalchardet - juniversalchardet - ${juniversalchardet.version} - - - - - com.github.junrar - junrar - ${junrar.version} - - - net.sourceforge.jchardet - jchardet - ${jchardet.version} - - - antlr - antlr - ${antlr.version} - - - commons-cli - commons-cli - ${commons-cli.version} - - - - - commons-net - commons-net - ${commons-net.version} - - - com.thoughtworks.xstream - xstream - ${xstream.version} - - - com.googlecode.concurrentlinkedhashmap - concurrentlinkedhashmap-lru - ${concurrentlinkedhashmap.version} - - - org.rocksdb - rocksdbjni - ${rocksdb.version} - + org.apache.pdfbox pdfbox @@ -188,6 +115,30 @@ pdfbox-tools ${pdfbox.version} + + com.itextpdf + itextpdf + ${itextpdf.version} + + + + + net.sf.sevenzipjbinding + sevenzipjbinding + ${sevenzipjbinding.version} + + + net.sf.sevenzipjbinding + sevenzipjbinding-all-platforms + ${sevenzipjbinding.version} + + + com.github.junrar + junrar + ${junrar.version} + + + com.github.jai-imageio jai-imageio-jpeg2000 @@ -203,79 +154,12 @@ jbig2-imageio ${jbig2-imageio.version} - - com.aspose - aspose-cad - ${aspose-cad.version} - - - org.bouncycastle - bcprov-jdk15on - ${bcprov-jdk15on.version} + org.apache.commons + commons-imaging + ${commons-imaging.version} - - - io.mola.galimatias - galimatias - ${galimatias.version} - - - - - org.bytedeco - javacv - ${bytedeco.version} - - - org.bytedeco - javacpp - ${bytedeco.version} - - - - - org.bytedeco - opencv - ${opencv.version} - linux-x86_64 - - - org.bytedeco - opencv - ${opencv.version} - windows-x86_64 - - - org.bytedeco - openblas - ${openblas.version} - linux-x86_64 - - - org.bytedeco - openblas - ${openblas.version} - windows-x86_64 - - - org.bytedeco - ffmpeg - ${ffmpeg.version} - linux-x86_64 - - - org.bytedeco - ffmpeg - ${ffmpeg.version} - windows-x86_64 - - - com.itextpdf - itextpdf - ${itextpdf.version} - - + javax.media jai_core @@ -291,7 +175,129 @@ ${pom.basedir}/lib/jai_codec-1.1.3.jar - + + + org.bytedeco + javacv + ${bytedeco.version} + + + org.bytedeco + javacpp + ${bytedeco.version} + + + org.bytedeco + opencv + ${opencv.version} + linux-x86_64 + + + org.bytedeco + opencv + ${opencv.version} + windows-x86_64 + + + org.bytedeco + openblas + ${openblas.version} + linux-x86_64 + + + org.bytedeco + openblas + ${openblas.version} + windows-x86_64 + + + org.bytedeco + ffmpeg + ${ffmpeg.version} + linux-x86_64 + + + org.bytedeco + ffmpeg + ${ffmpeg.version} + windows-x86_64 + + + + + org.apache.httpcomponents.client5 + httpclient5 + + + commons-net + commons-net + ${commons-net.version} + + + + + org.redisson + redisson + ${redisson.version} + + + org.rocksdb + rocksdbjni + ${rocksdb.version} + + + com.googlecode.concurrentlinkedhashmap + concurrentlinkedhashmap-lru + ${concurrentlinkedhashmap.version} + + + + + com.googlecode.juniversalchardet + juniversalchardet + ${juniversalchardet.version} + + + net.sourceforge.jchardet + jchardet + ${jchardet.version} + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + commons-cli + commons-cli + ${commons-cli.version} + + + + + antlr + antlr + ${antlr.version} + + + com.thoughtworks.xstream + xstream + ${xstream.version} + + + org.bouncycastle + bcprov-jdk15on + ${bcprov-jdk15on.version} + + + io.mola.galimatias + galimatias + ${galimatias.version} + + + org.springframework.boot spring-boot-starter-test @@ -309,7 +315,6 @@ - diff --git a/server/src/main/java/cn/keking/utils/ConvertPicUtil.java b/server/src/main/java/cn/keking/utils/ConvertPicUtil.java index e219c051..f00761d6 100644 --- a/server/src/main/java/cn/keking/utils/ConvertPicUtil.java +++ b/server/src/main/java/cn/keking/utils/ConvertPicUtil.java @@ -1,6 +1,7 @@ package cn.keking.utils; import cn.keking.config.ConfigConstants; +import cn.keking.service.FileHandlerService; import cn.keking.web.filter.BaseUrlFilter; import com.itextpdf.text.Document; import com.itextpdf.text.Image; @@ -8,14 +9,12 @@ import com.itextpdf.text.io.FileChannelRandomAccessSource; import com.itextpdf.text.pdf.PdfWriter; import com.itextpdf.text.pdf.RandomAccessFileOrArray; import com.itextpdf.text.pdf.codec.TiffImage; -import com.sun.media.jai.codec.*; +import org.apache.commons.imaging.Imaging; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import javax.media.jai.JAI; -import javax.media.jai.RenderedOp; -import java.awt.image.RenderedImage; -import java.awt.image.renderable.ParameterBlock; +import javax.imageio.ImageIO; +import java.awt.image.BufferedImage; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -40,58 +39,54 @@ public class ConvertPicUtil { public static List convertTif2Jpg(String strInputFile, String strOutputFile, boolean forceUpdatedCache) throws Exception { List listImageFiles = new ArrayList<>(); String baseUrl = BaseUrlFilter.getBaseUrl(); - if (!new File(strInputFile).exists()) { - logger.info("找不到文件【" + strInputFile + "】"); + strOutputFile = strOutputFile.substring(0, strOutputFile.lastIndexOf('.')); + + File tiffFile = new File(strInputFile); + if (!tiffFile.exists()) { + logger.info("找不到文件【{}】", strInputFile); return null; } - strOutputFile = strOutputFile.replaceAll(".jpg", ""); - FileSeekableStream fileSeekStream = null; + + File outputDir = new File(strOutputFile); + if (!outputDir.exists() && !outputDir.mkdirs()) { + throw new IOException("创建目录失败: " + strOutputFile); + } + + List images; try { - JPEGEncodeParam jpegEncodeParam = new JPEGEncodeParam(); - TIFFEncodeParam tiffEncodeParam = new TIFFEncodeParam(); - tiffEncodeParam.setCompression(TIFFEncodeParam.COMPRESSION_GROUP4); - tiffEncodeParam.setLittleEndian(false); - fileSeekStream = new FileSeekableStream(strInputFile); - ImageDecoder imageDecoder = ImageCodec.createImageDecoder("TIFF", fileSeekStream, null); - int intTifCount = imageDecoder.getNumPages(); - // logger.info("该tif文件共有【" + intTifCount + "】页"); - // 处理目标文件夹,如果不存在则自动创建 - File fileJpgPath = new File(strOutputFile); - if (!fileJpgPath.exists() && !fileJpgPath.mkdirs()) { - logger.error("{} 创建失败", strOutputFile); - } - // 循环,处理每页tif文件,转换为jpg - for (int i = 0; i < intTifCount; i++) { - String strJpg= strOutputFile + "/" + i + ".jpg"; - File fileJpg = new File(strJpg); - // 如果文件不存在,则生成 - if (forceUpdatedCache|| !fileJpg.exists()) { - RenderedImage renderedImage = imageDecoder.decodeAsRenderedImage(i); - ParameterBlock pb = new ParameterBlock(); - pb.addSource(renderedImage); - pb.add(fileJpg.toString()); - pb.add("JPEG"); - pb.add(jpegEncodeParam); - RenderedOp renderedOp = JAI.create("filestore", pb); - renderedOp.dispose(); - // logger.info("每页分别保存至: " + fileJpg.getCanonicalPath()); + images = Imaging.getAllBufferedImages(tiffFile); + for (int i = 0; i < images.size(); i++) { + String fileName = strOutputFile + File.separator + i + ".jpg"; + File outputFile = new File(fileName); + + // 如果需要强制更新缓存或者文件不存在,则转换 + if (forceUpdatedCache || !outputFile.exists()) { + BufferedImage image = images.get(i); + // 写入JPG格式 + boolean success = ImageIO.write(image, "png", outputFile); + if (!success) { + throw new IOException("无法写入JPG格式图片: " + fileName); + } + logger.debug("转换图片: {}", fileName); + } else { + logger.debug("使用缓存图片: {}", fileName); } - strJpg = baseUrl+strJpg.replace(fileDir, ""); - listImageFiles.add(strJpg); + + // 构建URL + String relativePath = fileName.replace(fileDir, ""); + String url = baseUrl + WebUtils.encodeFileName(relativePath); + listImageFiles.add(url); } } catch (IOException e) { - if (!e.getMessage().contains("Bad endianness tag (not 0x4949 or 0x4d4d)") ) { - logger.error("TIF转JPG异常,文件路径:" + strInputFile, e); + if (!e.getMessage().contains("Only sequential, baseline JPEGs are supported at the moment")) { + logger.error("TIF转JPG异常,文件路径:{}", strInputFile, e); } throw new Exception(e); - } finally { - if (fileSeekStream != null) { - fileSeekStream.close(); - } } return listImageFiles; } + /** * 将Jpg图片转换为Pdf文件 * @@ -113,9 +108,9 @@ public class ConvertPicUtil { document.open(); Image image; for (int i = 1; i <= pages; i++) { - image = TiffImage.getTiffImage(rafa, i); - image.scaleToFit(FIT_WIDTH, FIT_HEIGHT); - document.add(image); + image = TiffImage.getTiffImage(rafa, i); + image.scaleToFit(FIT_WIDTH, FIT_HEIGHT); + document.add(image); } } catch (IOException e) { if (!e.getMessage().contains("Bad endianness tag (not 0x4949 or 0x4d4d)") ) { diff --git a/server/src/main/resources/static/js/UTIF.js b/server/src/main/resources/static/js/UTIF.js index d359c282..7bd68b61 100644 --- a/server/src/main/resources/static/js/UTIF.js +++ b/server/src/main/resources/static/js/UTIF.js @@ -35,17 +35,42 @@ if(this.p>4){throw new W("Unsupported color mode")}var E=this.Y(h,f,n);if(this.p UTIF.encodeImage = function(rgba, w, h, metadata) { - var idf = { "t256":[w], "t257":[h], "t258":[8,8,8,8], "t259":[1], "t262":[2], "t273":[1000], // strips offset - "t277":[4], "t278":[h], /* rows per strip */ "t279":[w*h*4], // strip byte counts + var bpv = Math.round(rgba.byteLength/(w*h*4)); + var dpth = bpv*8; + var img = new Uint8Array(rgba); + if(dpth==16) { + img=img.slice(0); for(var i=0; i>>1)), prts = [], offs = [], bcnt = [], tsz=0; + var psz = 1000+(metadata?1000:0)+Math.ceil(h/rps)*8; + + for(var y=0; y3) img["t258"]=img["t258"].slice(0,3); + if(cmpr==7 && img["t258"] && img["t258"].length!=3 && img["t258"][0]==8) { img["t258"]=[8,8,8]; img["t277"]=[3]; } // not for lossless JPEG - "RAW_CANON_EOS_550D.CR2" + if(img["t277"]==null && img["t258"] && img["t258"].length==3) img["t277"]=[3]; // t277 missing in some 3-channel JPGs inside CR2 - "RAW_CANON_350D.CR2" - var spp = img["t277"]?img["t277"][0]:1; var bps = img["t258"]?img["t258"][0]:1; + var spp = img["t277"]?img["t277"][0]:1; //if(cmpr==7) spp=3; // jpg + var pco = img["t284"]?img["t284"][0]:1; if(spp!=3) pco=1; // planar configuration + if(pco==2) log("PlanarConfiguration 2 should not be used!"); + var bipp = bps*spp; // bits per pixel /* var bipp; // bits per pixel @@ -150,7 +178,17 @@ UTIF.decodeImage = function(buff, img, ifds) //console.log("====", img.width, rps); for(var i=0; i>>3, bpl = Math.ceil(bps*noc*w/8); + var pco = img["t284"] ? img["t284"][0] : 1; // planar configuration + var bps = (img["t258"]?Math.min(64,img["t258"][0]):1); + var noc = pco==2 ? 1 : (img["t277"]?img["t277"][0]:1), bpp=(bps*noc)>>>3, bpl = Math.ceil(bps*noc*w/8); // convert to Little Endian /* if(bps==16 && !img.isLE && img["t33422"]==null) // not DNG @@ -195,10 +237,9 @@ UTIF.decode._decompress = function(img,ifds, data, off, len, cmpr, tgt, toff, fo for(var x=1; x> 6) + 4 * (bytes[2]) + ((bytes[3] & 0xF) << 10); + result[idx + 2] = (bytes[3] >> 4) + 16 * (bytes[4]) + ((bytes[5] & 3) << 12); + result[idx + 3] = ((bytes[5] & 0xFC) >> 2) + (bytes[6] << 6); + result[idx + 4] = bytes[7] + ((bytes[8] & 0x3F) << 8); + result[idx + 5] = (bytes[8] >> 6) + 4 * bytes[9] + ((bytes[10] & 0xF) << 10); + result[idx + 6] = (bytes[10] >> 4) + 16 * bytes[11] + ((bytes[12] & 3) << 12); + result[idx + 7] = ((bytes[12] & 0xFC) >> 2) + (bytes[13] << 6); + result[idx + 8] = bytes[14] + ((bytes[15] & 0x3F) << 8); + //ix+=9; + //if(ix>=rawWidth/9) ix=(ix%9)+1; + } + } //*/ // Skatch of version 7 /* @@ -612,6 +676,19 @@ UTIF.decode._decodeNikon = function(img,imgs, data, off, src_length, tgt, toff) var getbithuff = UTIF.decode._getbithuff; var mn = imgs[0].exifIFD.makerNote, md = mn["t150"]?mn["t150"]:mn["t140"], mdo=0; //console.log(mn,md); + + if(mn["t147"] && mn["t147"][0]==2) { + var ppl = Math.ceil(raw_width/10); + var bpl = ppl*16; + var rbpl = (raw_width*3)>>>1; + for(var y=0; ydata.buffer.byteLength) num=data.buffer.byteLength-no; arr = new Uint8Array(data.buffer, no, num); } if(type== 2) { var o0 = (num<5 ? offset-4 : voff), c=data[o0], len=Math.max(0, Math.min(num-1,data.length-o0)); - if(c<128 || len==0) arr.push( bin.readASCII(data, o0, len) ); + if(c<128 || len==0) { arr.push( bin.readASCII(data, o0, len) ); if(arr[0].endsWith("\u0000")) arr[0]=arr[0].slice(0,-1); } else arr = new Uint8Array(data.buffer, o0, len); } if(type== 3) { for(var j=0; j>3)])>>(7- (i&7)))&1; img[qi]=img[qi+1]=img[qi+2]=(px)*255; img[qi+3]=255; } if(bps== 2) for(var i=0; i>2)])>>(6-2*(i&3)))&3; img[qi]=img[qi+1]=img[qi+2]=(px)* 85; img[qi+3]=255; } - if(bps== 8) for(var i=0; i>>2)+i, px=f32[o]; img[qi]=img[qi+1]=img[qi+2]= ~~(0.5+255*px); img[qi+3]=255; } + if(bps==64) for(var i=0; i>>3)+i, px=f64[o]; img[qi]=img[qi+1]=img[qi+2]= ~~(0.5+255*px); img[qi+3]=255; } } } else if(intp==2) @@ -1406,7 +1506,7 @@ UTIF.toRGBA8 = function(out, scl) for(var i=0; ie ? fz3 : (116*fz-16)/k; + var yr = fy3>e ? fy3 : (116*fy-16)/k; + var xr = fx3>e ? fx3 : (116*fx-16)/k; + + var X = xr*(96.42/100), Y = yr*(100/100), Z = zr*(82.49/100); + + img[qi ] = Math.max(0, Math.min(255, gamma(X*M[0] + Y*M[1] + Z*M[2])*255)); + img[qi+1] = Math.max(0, Math.min(255, gamma(X*M[3] + Y*M[4] + Z*M[5])*255)); + img[qi+2] = Math.max(0, Math.min(255, gamma(X*M[6] + Y*M[7] + Z*M[8])*255)); + img[qi+3] = 255; + } + } else if(intp==32845) { for(var y=0; y>>2<<5);while(i==0){i=n(N,d,1);m=n(N,d+1,2);d+=3;if(m==0){if((d&7)!=0)d+=8-(d&7); - var D=(d>>>3)+4,q=N[D-4]|N[D-3]<<8;if(Z)W=H.H.W(W,w+q);W.set(new R(N.buffer,N.byteOffset+D,q),w);d=D+q<<3; - w+=q;continue}if(Z)W=H.H.W(W,w+(1<<17));if(m==1){v=b.J;C=b.h;X=(1<<9)-1;u=(1<<5)-1}if(m==2){J=A(N,d,5)+257; - h=A(N,d+5,5)+1;Q=A(N,d+10,4)+4;d+=14;var E=d,j=1;for(var c=0;c<38;c+=2){b.Q[c]=0;b.Q[c+1]=0}for(var c=0; - cj)j=K}d+=3*Q;M(b.Q,j);I(b.Q,j,b.u);v=b.w;C=b.d; - d=l(b.u,(1<>>4;if(p>>>8==0){W[w++]=p}else if(p==256){break}else{var z=w+p-254; - if(p>264){var _=b.q[p-257];z=w+(_>>>3)+A(N,d,_&7);d+=_&7}var $=C[e(N,d)&u];d+=$&15;var s=$>>>4,Y=b.c[s],a=(Y>>>4)+n(N,d,Y&15); - d+=Y&15;while(w>>4; - if(b<=15){A[I]=b;I++}else{var Z=0,m=0;if(b==16){m=3+l(V,n,2);n+=2;Z=A[I-1]}else if(b==17){m=3+l(V,n,3); - n+=3}else if(b==18){m=11+l(V,n,7);n+=7}var J=I+m;while(I>>1; - while(An)n=M;A++}while(A>1,I=N[l+1],e=M<<4|I,b=W-I,Z=N[l]<>>15-W;R[J]=e;Z++}}};H.H.l=function(N,W){var R=H.H.m.r,V=15-W;for(var n=0;n>>V}};H.H.M=function(N,W,R){R=R<<(W&7);var V=W>>>3;N[V]|=R;N[V+1]|=R>>>8}; - H.H.I=function(N,W,R){R=R<<(W&7);var V=W>>>3;N[V]|=R;N[V+1]|=R>>>8;N[V+2]|=R>>>16};H.H.e=function(N,W,R){return(N[W>>>3]|N[(W>>>3)+1]<<8)>>>(W&7)&(1<>>3]|N[(W>>>3)+1]<<8|N[(W>>>3)+2]<<16)>>>(W&7)&(1<>>3]|N[(W>>>3)+1]<<8|N[(W>>>3)+2]<<16)>>>(W&7)}; - H.H.i=function(N,W){return(N[W>>>3]|N[(W>>>3)+1]<<8|N[(W>>>3)+2]<<16|N[(W>>>3)+3]<<24)>>>(W&7)};H.H.m=function(){var N=Uint16Array,W=Uint32Array; - return{K:new N(16),j:new N(16),X:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],S:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999],T:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],q:new N(32),p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535],z:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],c:new W(32),J:new N(512),_:[],h:new N(32),$:[],w:new N(32768),C:[],v:[],d:new N(32768),D:[],u:new N(512),Q:[],r:new N(1<<15),s:new W(286),Y:new W(30),a:new W(19),t:new W(15e3),k:new N(1<<16),g:new N(1<<15)}}(); - (function(){var N=H.H.m,W=1<<15;for(var R=0;R>>1|(V&1431655765)<<1; - V=(V&3435973836)>>>2|(V&858993459)<<2;V=(V&4042322160)>>>4|(V&252645135)<<4;V=(V&4278255360)>>>8|(V&16711935)<<8; - N.r[R]=(V>>>16|V<<16)>>>17}function n(A,l,M){while(l--!=0)A.push(0,M)}for(var R=0;R<32;R++){N.q[R]=N.S[R]<<3|N.T[R]; - N.c[R]=N.p[R]<<4|N.z[R]}n(N._,144,8);n(N._,255-143,9);n(N._,279-255,7);n(N._,287-279,8);H.H.n(N._,9); - H.H.A(N._,9,N.J);H.H.l(N._,9);n(N.$,32,5);H.H.n(N.$,5);H.H.A(N.$,5,N.h);H.H.l(N.$,5);n(N.Q,19,0);n(N.C,286,0); - n(N.D,30,0);n(N.v,320,0)}());return H.H.N}(); +UTIF._inflateRaw=function(){var D=function(){var o=Uint16Array,j=Uint32Array;return{m:new o(16),v:new o(16), + d:[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],o:[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,999,999,999], + z:[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0],B:new o(32), + p:[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,65535,65535], + w:[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0],h:new j(32),g:new o(512),s:[],A:new o(32),t:[],k:new o(32768),c:[], + a:[],n:new o(32768),e:[],C:new o(512),b:[],i:new o(1<<15),r:new j(286),f:new j(30),l:new j(19),u:new j(15e3),q:new o(1<<16),j:new o(1<<15)}}(); +function C(o,j){var I=o.length,A,r,i,y,G,f=D.v;for(var y=0;y<=j;y++)f[y]=0;for(y=1;y>1,G=o[i+1],f=y<<4|G,a=j-G,k=o[i]<>>15-j;I[x]=f;k++}}}function g(o,j){var I=D.i,A=15-j;for(var r=0;r>>A}}(function(){var o=1<<15;for(var j=0;j>>1|(I&1431655765)<<1; +I=(I&3435973836)>>>2|(I&858993459)<<2;I=(I&4042322160)>>>4|(I&252645135)<<4;I=(I&4278255360)>>>8|(I&16711935)<<8; +D.i[j]=(I>>>16|I<<16)>>>17}function A(r,i,y){while(i--!=0)r.push(0,y)}for(var j=0;j<32;j++){D.B[j]=D.o[j]<<3|D.z[j]; +D.h[j]=D.p[j]<<4|D.w[j]}A(D.s,144,8);A(D.s,255-143,9);A(D.s,279-255,7);A(D.s,287-279,8);C(D.s,9);t(D.s,9,D.g); +g(D.s,9);A(D.t,32,5);C(D.t,5);t(D.t,5,D.A);g(D.t,5);A(D.b,19,0);A(D.c,286,0);A(D.e,30,0);A(D.a,320,0)}()); +function F(o,j,I){return(o[j>>>3]|o[(j>>>3)+1]<<8)>>>(j&7)&(1<>>3]|o[(j>>>3)+1]<<8|o[(j>>>3)+2]<<16)>>>(j&7)&(1<>>3]|o[(j>>>3)+1]<<8|o[(j>>>3)+2]<<16)>>>(j&7)}function b(o,j){return(o[j>>>3]|o[(j>>>3)+1]<<8|o[(j>>>3)+2]<<16|o[(j>>>3)+3]<<24)>>>(j&7)} +function v(o,j){var I=Uint8Array,r=0,i=0,y=0,G=0,f=0,a=0,k=0,N=0,x=0,P,J; +if(o[0]==3&&o[1]==0)return j?j:new I(0);var A=j==null;if(A)j=new I(o.length>>>2<<3);while(r==0){r=s(o,x,1); +i=s(o,x+1,2);x+=3;if(i==0){if((x&7)!=0)x+=8-(x&7);var K=(x>>>3)+4,m=o[K-4]|o[K-3]<<8;if(A)j=H(j,N+m); +j.set(new I(o.buffer,o.byteOffset+K,m),N);x=K+m<<3;N+=m;continue}if(A)j=H(j,N+(1<<17));if(i==1){P=D.g; +J=D.A;a=(1<<9)-1;k=(1<<5)-1}if(i==2){y=F(o,x,5)+257;G=F(o,x+5,5)+1;f=F(o,x+10,4)+4;x+=14;var O=x,Q=1; +for(var p=0;p<38;p+=2){D.b[p]=0;D.b[p+1]=0}for(var p=0;pQ)Q=l}x+=3*f;C(D.b,Q);t(D.b,Q,D.C);P=D.k;J=D.n;x=B(D.C,(1<>>4;if(L>>>8==0){j[N++]=L}else if(L==256){break}else{var M=N+L-254;if(L>264){var z=D.B[L-257]; +M=N+(z>>>3)+F(o,x,z&7);x+=z&7}var e=J[w(o,x)&k];x+=e&15;var E=e>>>4,c=D.h[E],q=(c>>>4)+s(o,x,c&15);x+=c&15; +if(A)j=H(j,N+(1<<17));while(N>>4;if(f<=15){i[y]=f;y++}else{var a=0,k=0;if(f==16){k=3+F(A,r,2); +r+=2;a=i[y-1]}else if(f==17){k=3+F(A,r,3);r+=3}else if(f==18){k=11+F(A,r,7);r+=7}var N=y+k;while(y>>1;while(ir)r=G;i++}while(i>--s&1; -Y=I[Y+F]}E[w]=Y}}function z(h,V,I,f){if(h[V+3]!=255)return 0;if(I==0)return V;for(var w=0;w<2;w++){if(h[V+w]==0){h[V+w]=h.length; -h.push(0,0,f,255)}var x=z(h,h[V+w],I-1,f+1);if(x!=0)return x}return 0}function i(h){var V=h.b,I=h.f; -while(V<25&&h.a>(V.b-=h)&65535>>16-h}function g(h,V){var I=h[0],f=0,w=255,x=0;if(V.b<16)i(V);var T=V.f>>V.b-8&255; -f=h[1][T];w=I[f+3];V.b-=I[f+2];while(w==255){x=V.f>>--V.b&1;f=I[f+x];w=I[f+3]}return w}function P(h,V){if(h<32768>>16-V)h+=-(1<>4,J&15]}}else if(Y==65476){var a3=O+F-2;while(O>>4];x[v[0]]=v.slice(1)}I=l();O+=2;break}else if(Y==65501){w=m()}else{O+=F-2}}var a4=f>8?Uint16Array:Uint8Array,$=new a4(s*_*E),M={b:0,f:0,c:I==8,a:O,data:b,d:b.length,e:w}; -if(M.c)a1($,_*E,M,G[0],s);else{var c=[],p=0,D=0;for(var t=0;tp)p=S; -if(K>D)D=K;c.push(S*K)}if(p!=1||D!=1){if(E!=3||c[1]!=1||c[2]!=1)throw"e";if(p!=2||D!=1&&D!=2)throw"e"; -var u=[],Z=0;for(var t=0;t>>1)*B+(S>>>1))*Z,y=(K&1)*2+(S&1); -$[q]=n[k+y];$[q+1]=n[k+4];$[q+2]=n[k+5]}else for(var S=0;S<_;S++){var q=(K*_+S)*E,k=(K*B+(S>>>1))*Z,y=S&1; -$[q]=n[k+y];$[q+1]=n[k+2];$[q+2]=n[k+3]}}}else{X($,_*E,M,G,E,s);if(w==0)j($,I,_,s,0,E,E,f);else{var U=Math.floor(w/_); -for(var K=0;K>>1);else if(V==6)Q=h[J]+(r-h[J-G]>>>1);else if(V==7)Q=r+h[J]>>>1;else throw V; -h[a]+=Q}}}}return C}(); +UTIF.LosslessJpegDecode =function(){var Z,D;function A(){return Z[D++]}function J(){return Z[D++]<<8|Z[D++]}function a3(R){var f=A(),S=[0,0,0,255],H=[],G=8; +for(var y=0;y<16;y++)H[y]=A();for(var y=0;y<16;y++){for(var m=0;m>--Y&1; +d=S[d+s]}u[y]=d}}function r(R,f,S,H){if(R[f+3]!=255)return 0;if(S==0)return f;for(var y=0;y<2;y++){if(R[f+y]==0){R[f+y]=R.length; +R.push(0,0,H,255)}var m=r(R,R[f+y],S-1,H+1);if(m!=0)return m}return 0}function C(R){var f=R.c,S=R.f; +while(f<25&&R.d>(f.c-=R)&65535>>16-R}function P(R,f){var S=R[0],H=0,y=255,m=0;if(f.c<16)C(f);var t=f.f>>f.c-8&255; +H=R[1][t];y=S[H+3];f.c-=S[H+2];while(y==255){m=f.f>>--f.c&1;H=S[H+m];y=S[H+3]}return y}function e(R,f){if(R<32768>>16-f)R+=-(1<>4,z&15]}}else if(d==65476){var a5=D+s-2;while(D>>4];m[b[0]]=b.slice(1)}S=A();D+=2;break}else if(d==65501){y=J()}else{D+=s-2}}var a4=H>8?Uint16Array:Uint8Array,h=new a4(Y*_*u),c={c:0,f:0,b:S==8,d:D,data:Z,a:Z.length,e:y}; +if(c.b)a2(h,_*u,c,G[0],Y);else{var x=[],V=0,T=0;for(var F=0;FV)V=O; +if(w>T)T=w;x.push(O*w)}if(V!=1||T!=1){if(u!=3||x[1]!=1||x[2]!=1)throw"e";if(V!=2||T!=1&&T!=2)throw"e"; +var N=[],L=0;for(var F=0;F>>1)*B+(O>>>1))*L,j=(w&1)*2+(O&1); +h[X]=q[n+j];h[X+1]=q[n+4];h[X+2]=q[n+5]}else for(var O=0;O<_;O++){var X=(w*_+O)*u,n=(w*B+(O>>>1))*L,j=O&1; +h[X]=q[n+j];h[X+1]=q[n+2];h[X+2]=q[n+3]}}}else{I(h,_*u,c,G,u,Y);if(y==0)M(h,S,_,Y,0,u,u,H);else{var Q=Math.floor(y/_); +for(var w=0;w>>1);else if(f==6)g=R[z]+(o-R[z-G]>>>1);else if(f==7)g=o+R[z]>>>1;else throw f; +R[p]+=g}}}}return l}(); + (function(){var G=0,F=1,i=2,b=3,J=4,N=5,E=6,s=7,c=8,T=9,a3=10,f=11,q=12,M=13,m=14,x=15,L=16,$=17,p=18;