Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "thumbhash", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A very compact representation of an image placeholder", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/evanw/thumbhash" | ||
}, | ||
"type": "module", | ||
@@ -6,0 +10,0 @@ "main": "thumbhash.js", |
@@ -9,3 +9,3 @@ /** | ||
*/ | ||
export function rgbaToThumbHash(w: number, h: number, rgba: readonly ArrayLike<number>): Uint8Array | ||
export function rgbaToThumbHash(w: number, h: number, rgba: ArrayLike<number>): Uint8Array | ||
@@ -18,3 +18,3 @@ /** | ||
*/ | ||
export function thumbHashToRGBA(hash: readonly ArrayLike<number>): { w: number, h: number, rgba: Uint8Array } | ||
export function thumbHashToRGBA(hash: ArrayLike<number>): { w: number, h: number, rgba: Uint8Array } | ||
@@ -27,3 +27,3 @@ /** | ||
*/ | ||
export function thumbHashToAverageRGBA(hash: readonly ArrayLike<number>): { r: number, g: number, b: number, a: number } | ||
export function thumbHashToAverageRGBA(hash: ArrayLike<number>): { r: number, g: number, b: number, a: number } | ||
@@ -36,3 +36,3 @@ /** | ||
*/ | ||
export function thumbHashToApproximateAspectRatio(hash: readonly ArrayLike<number>): number | ||
export function thumbHashToApproximateAspectRatio(hash: ArrayLike<number>): number | ||
@@ -49,3 +49,3 @@ /** | ||
*/ | ||
export function rgbaToDataURL(w: number, h: number, rgba: readonly ArrayLike<number>): string | ||
export function rgbaToDataURL(w: number, h: number, rgba: ArrayLike<number>): string | ||
@@ -59,2 +59,2 @@ /** | ||
*/ | ||
export function thumbHashToDataURL(hash: readonly ArrayLike<number>): string | ||
export function thumbHashToDataURL(hash: ArrayLike<number>): string |
@@ -0,1 +1,9 @@ | ||
/** | ||
* Encodes an RGBA image to a ThumbHash. RGB should not be premultiplied by A. | ||
* | ||
* @param w The width of the input image. Must be ≤100px. | ||
* @param h The height of the input image. Must be ≤100px. | ||
* @param rgba The pixels in the input image, row-by-row. Must have w*h*4 elements. | ||
* @returns The ThumbHash as a Uint8Array. | ||
*/ | ||
export function rgbaToThumbHash(w, h, rgba) { | ||
@@ -88,2 +96,8 @@ // Encoding an image larger than 100x100 is slow with no benefit | ||
/** | ||
* Decodes a ThumbHash to an RGBA image. RGB is not be premultiplied by A. | ||
* | ||
* @param hash The bytes of the ThumbHash. | ||
* @returns The width, height, and pixels of the rendered placeholder image. | ||
*/ | ||
export function thumbHashToRGBA(hash) { | ||
@@ -171,2 +185,8 @@ let { PI, min, max, cos, round } = Math | ||
/** | ||
* Extracts the average color from a ThumbHash. RGB is not be premultiplied by A. | ||
* | ||
* @param hash The bytes of the ThumbHash. | ||
* @returns The RGBA values for the average color. Each value ranges from 0 to 1. | ||
*/ | ||
export function thumbHashToAverageRGBA(hash) { | ||
@@ -191,2 +211,8 @@ let { min, max } = Math | ||
/** | ||
* Extracts the approximate aspect ratio of the original image. | ||
* | ||
* @param hash The bytes of the ThumbHash. | ||
* @returns The approximate aspect ratio (i.e. width / height). | ||
*/ | ||
export function thumbHashToApproximateAspectRatio(hash) { | ||
@@ -201,2 +227,12 @@ let header = hash[3] | ||
/** | ||
* Encodes an RGBA image to a PNG data URL. RGB should not be premultiplied by | ||
* A. This is optimized for speed and simplicity and does not optimize for size | ||
* at all. This doesn't do any compression (all values are stored uncompressed). | ||
* | ||
* @param w The width of the input image. Must be ≤100px. | ||
* @param h The height of the input image. Must be ≤100px. | ||
* @param rgba The pixels in the input image, row-by-row. Must have w*h*4 elements. | ||
* @returns A data URL containing a PNG for the input image. | ||
*/ | ||
export function rgbaToDataURL(w, h, rgba) { | ||
@@ -246,2 +282,9 @@ let row = w * 4 + 1 | ||
/** | ||
* Decodes a ThumbHash to a PNG data URL. This is a convenience function that | ||
* just calls "thumbHashToRGBA" followed by "rgbaToDataURL". | ||
* | ||
* @param hash The bytes of the ThumbHash. | ||
* @returns A data URL containing a PNG for the rendered ThumbHash. | ||
*/ | ||
export function thumbHashToDataURL(hash) { | ||
@@ -248,0 +291,0 @@ let image = thumbHashToRGBA(hash) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
12852
318
0