Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Since last update of UTIF was 18/6/2019 and Photopea does not touch npm at all and neither 3rd party developer is keeping package up to date with GitHub repo... this package is just updated version of utif (from npm) but with many improvements.
A small, fast and advanced TIFF / EXIF (+ DNG, CR2, NEF and other TIFF-ish files) decoder and encoder. It is the main TIFF library for Photopea image editor. Try to open your TIFF file with Photopea to see, if UTIF.js can parse it.
For RAW files, UTIF.js only decodes raw sensor data (and JPG previews, if there are any). It does not convert the raw data into a displayable image (RGBA). Such conversion is complex and out of scope of this library.
Download and include the UTIF.js
file in your code. If you're in NodeJS or otherwise using NPM, run:
npm install utif
UTIF.decode(buffer)
buffer
: ArrayBuffer containing TIFF or EXIF dataUTIF.decodeImage(buffer, ifd)
buffer
: ArrayBuffer containing TIFF or EXIF dataifd
: the element of the output of UTIF.decode()width
: the width of the imageheight
: the height of the imagedata
: decompressed pixel data of the imageTIFF files may have various number of channels and various color depth. The interpretation of data
depends on many tags (see the TIFF 6 specification). The following function converts any TIFF image into a 8-bit RGBA image.
UTIF.toRGBA8(ifd)
ifd
: image file directory (element of "ifds" returned by UTIF.decode(), processed by UTIF.decodeImage())function imgLoaded(e) {
var ifds = UTIF.decode(e.target.response);
UTIF.decodeImage(e.target.response, ifds[0])
var rgba = UTIF.toRGBA8(ifds[0]); // Uint8Array with RGBA pixels
console.log(ifds[0].width, ifds[0].height, ifds[0]);
}
var xhr = new XMLHttpRequest();
xhr.open("GET", "my_image.tif");
xhr.responseType = "arraybuffer";
xhr.onload = imgLoaded; xhr.send();
If you are not a programmer, you can use TIFF images directly inside the <img>
element of HTML. Then, it is enough to call UTIF.replaceIMG()
once at some point.
UTIF.replaceIMG()
<body onload="UTIF.replaceIMG()">
...
<img src="image.tif" /> <img src="dog.tif" /> ...
And UTIF.js will do the rest. Internally, the "src" attribute of the image will be replaced with a new URI of the image (base64-encoded PNG). Note, that you can also insert DNG, CR2, NEF and other raw images into HTML this way.
You should not save images into TIFF format in the 21st century. Save them as PNG instead (e.g. using UPNG.js). If you still want to use TIFF format for some reason, here it is.
UTIF.encodeImage(rgba, w, h, metadata)
rgba
: ArrayBuffer containing RGBA pixel dataw
: image widthh
: image heightmetadata
[optional]: IFD object (see below)UTIF.encode(ifds)
ifds
: array of IFDs (image file directories). An IFD is a JS object with properties "tXYZ" (where XYZ are TIFF tags)TIFF format sometimes uses Inflate algorithm for compression (but it is quite rare). Right now, UTIF.js calls Pako.js for the Inflate method.
FAQs
Fast and advanced TIFF decoder
The npm package utif2 receives a total of 368,979 weekly downloads. As such, utif2 popularity was classified as popular.
We found that utif2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.