chore: add jimp dependency, icon padding script, and update configuration

This commit is contained in:
2026-05-31 14:04:37 +02:00
parent 30f81045ac
commit 7cd17307ba
1126 changed files with 166400 additions and 2 deletions
Generated Vendored
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Photopea
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+86
View File
@@ -0,0 +1,86 @@
# UTIF2
## This is newer version of [UTIF](https://www.npmjs.com/package/utif)
Since last update of UTIF was 18/6/2019 and [Photopea does not touch npm](https://github.com/photopea/UTIF.js/issues/106) 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.
## About
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](https://www.photopea.com). Try to open your TIFF file with Photopea to see, if UTIF.js can parse it.
* Supports Black & White, Grayscale, RGB and Paletted images
* Supports Fax 3 and Fax 4 (CCITT), JPEG, LZW, PackBits and other compressions (1,3,4,5,6,7,8,32773,32809)
* E.g. [this 8 MPix image](//www.photopea.com/api/img/G4.TIF) with Fax 4 compression is just 56 kB ( [Open in Photopea](https://www.photopea.com?p=%7B%22files%22:%5B%22//www.photopea.com/api/img/G4.TIF%22%5D%7D) )
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.
## Installation
Download and include the `UTIF.js` file in your code. If you're in NodeJS or otherwise using NPM, run:
```sh
npm install utif
```
#### `UTIF.decode(buffer)`
* `buffer`: ArrayBuffer containing TIFF or EXIF data
* returns an array of "IFDs" (image file directories). Each IFD is an object, keys are "tXYZ" (XYZ is a TIFF tag number), values are values of these tags. You can get the the dimension (and other properties, "metadata") of the image without decompressing pixel data.
#### `UTIF.decodeImage(buffer, ifd)`
* `buffer`: ArrayBuffer containing TIFF or EXIF data
* `ifd`: the element of the output of UTIF.decode()
* If there is an image inside the IFD, it is decoded and three new properties are added to the IFD:
* * `width`: the width of the image
* * `height`: the height of the image
* * `data`: decompressed pixel data of the image
TIFF files may have various number of channels and various color depth. The interpretation of `data` depends on many tags (see the [TIFF 6 specification](http://www.npes.org/pdf/TIFF-v6.pdf)). 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())
* returns Uint8Array of the image in RGBA format, 8 bits per channel (ready to use in context2d.putImageData() etc.)
### Example
```javascript
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();
```
## Use TIFF images in HTML
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()`
```html
<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.
## Encoding TIFF images
You should not save images into TIFF format in the 21st century. Save them as PNG instead (e.g. using [UPNG.js](https://github.com/photopea/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 data
* `w`: image width
* `h`: image height
* `metadata` [optional]: IFD object (see below)
* returns ArrayBuffer of the binary TIFF file. No compression right now.
#### `UTIF.encode(ifds)`
* `ifds`: array of IFDs (image file directories). An IFD is a JS object with properties "tXYZ" (where XYZ are TIFF tags)
* returns ArrayBuffer of binary data. You can use it to encode EXIF data.
## Dependencies
TIFF format sometimes uses Inflate algorithm for compression (but it is quite rare). Right now, UTIF.js calls [Pako.js](https://github.com/nodeca/pako) for the Inflate method.
+72
View File
@@ -0,0 +1,72 @@
// Type definitions for utif 4.0.1
// Project: https://github.com/photopea/UTIF.js
// Definitions by: Jan Pesa <https://github.com/smajl>
// Naveen Kumar Sangi <https://github.com/nkprince007>
// Massimiliano Caniparoli <https://github.com/massic80>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import 'node';
export as namespace UTIF;
export type TiffTag = string[] | number[];
/**
* Each IFD is an object, keys are "tXYZ" (XYZ is a TIFF tag number), values are values of these tags.
* You can get the the dimension (and other properties, "metadata") of the image without decompressing pixel data.
* For more information on what each tag means, refer https://github.com/photopea/UTIF.js/blob/master/UTIF.js#L742 or TIFF 6 specification.
*/
// tslint:disable-next-line:interface-name
export interface IFD {
[property: string]: TiffTag | number | Uint8Array;
data: Uint8Array;
width: number;
height: number;
}
/**
* Returns an array of "IFDs" (image file directories).
*
* @param buffer A Buffer or ArrayBuffer containing TIFF or EXIF data.
*/
export function decode(buffer: Buffer | ArrayBuffer): IFD[];
/**
* If there is an image inside the IFD, it is decoded and three new properties are added to the IFD: width, height and data.
* Note: TIFF files may have various number of channels and various color depth. The interpretation of data depends on many tags (see the TIFF 6 specification).
*
* @param buffer A Buffer or ArrayBuffer containing TIFF or EXIF data
* @param ifd The element of the output of UTIF.decode()
*/
export function decodeImage(buffer: Buffer | ArrayBuffer, ifd: IFD): void;
/**
* Returns Uint8Array of the image in RGBA format, 8 bits per channel (ready to use in context2d.putImageData() etc.)
*
* @param ifd An image file directory
*/
export function toRGBA8(ifd: IFD): Uint8Array;
/**
* Returns an ArrayBuffer of the binary TIFF file.
* Note: No compression available right now.
*
* @param rgba A Uint8Array containing RGBA pixel data.
* @param w Width of the image.
* @param h Height of the image.
* @param metadata [optional] The image file directory which should be encoded.
*/
export function encodeImage(rgba: Uint8Array, w: number, h: number, metadata?: IFD): ArrayBuffer;
/**
* Returns ArrayBuffer of binary data which can be used to encode EXIF data.
*
* @param ifds The array of IFDs (image file directories) to be encoded.
*/
export function encode(ifds: IFD[]): ArrayBuffer;
/**
* Replaces all Image elements in the document with Canvas elements.
* The attributes "id", "class" and "style" will be copied from the original Image to the new Canvas.
*/
export function replaceIMG(): void;
Generated Vendored
+1649
View File
File diff suppressed because it is too large Load Diff
+27
View File
@@ -0,0 +1,27 @@
{
"name": "utif2",
"description": "Fast and advanced TIFF decoder",
"version": "4.1.0",
"homepage": "https://github.com/photopea/UTIF.js",
"author": "photopea (https://github.com/photopea)",
"contributors": [
"Photopea (https://github.com/photopea)",
"Jaroslav Bereza (https://github.com/jardicc)",
"Scimonster (https://github.com/Scimonster)"
],
"license": "MIT",
"repository": "github:photopea/UTIF.js",
"bugs": {
"url": "https://github.com/photopea/UTIF.js/issues"
},
"main": "UTIF",
"keywords": [
"tif",
"tiff",
"image",
"conversion"
],
"dependencies": {
"pako": "^1.0.11"
}
}