Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@napi-rs/image

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@napi-rs/image - npm Package Compare versions

Comparing version 1.4.4 to 1.5.0

78

index.d.ts

@@ -60,2 +60,61 @@ /* tslint:disable */

}
export const enum FastResizeFilter {
/**
* Each pixel of source image contributes to one pixel of the
* destination image with identical weights. For upscaling is equivalent
* of `Nearest` resize algorithm.
*/
Box = 0,
/**
* Bilinear filter calculate the output pixel value using linear
* interpolation on all pixels that may contribute to the output value.
*/
Bilinear = 1,
/**
* Hamming filter has the same performance as `Bilinear` filter while
* providing the image downscaling quality comparable to bicubic
* (`CatmulRom` or `Mitchell`). Produces a sharper image than `Bilinear`,
* doesn't have dislocations on local level like with `Box`.
* The filter don’t show good quality for the image upscaling.
*/
Hamming = 2,
/**
* Catmull-Rom bicubic filter calculate the output pixel value using
* cubic interpolation on all pixels that may contribute to the output
* value.
*/
CatmullRom = 3,
/**
* Mitchell–Netravali bicubic filter calculate the output pixel value
* using cubic interpolation on all pixels that may contribute to the
* output value.
*/
Mitchell = 4,
/**
* Lanczos3 filter calculate the output pixel value using a high-quality
* Lanczos filter (a truncated sinc) on all pixels that may contribute
* to the output value.
*/
Lanczos3 = 5
}
export const enum ResizeFit {
/**
* (default) Preserving aspect ratio
* ensure the image covers both provided dimensions by cropping/clipping to fit.
*/
Cover = 0,
/** Ignore the aspect ratio of the input and stretch to both provided dimensions. */
Fill = 1,
/**
* Preserving aspect ratio
* resize the image to be as large as possible while ensuring its dimensions are less than or equal to both those specified.
*/
Inside = 2
}
export interface FastResizeOptions {
width: number
height?: number
filter?: FastResizeFilter
fit?: ResizeFit
}
export interface JpegCompressOptions {

@@ -302,2 +361,8 @@ /** Output quality, default is 100 (lossless) */

}
export interface ResizeOptions {
width: number
height?: number
filter?: ResizeFilterType
fit?: ResizeFit
}
export class Transformer {

@@ -326,4 +391,13 @@ constructor(input: Buffer)

*/
resize(width: number, height?: number | undefined | null, filterType?: ResizeFilterType | undefined | null): this
resize(widthOrOptions: number | ResizeOptions, height?: number | undefined | null, filter?: ResizeFilterType | undefined | null, fit?: ResizeFit | undefined | null): this
/**
* Resize this image using the specified filter algorithm.
* The image is scaled to the maximum possible size that fits
* within the bounds specified by `width` and `height`.
*
* This is using faster SIMD based resize implementation
* the resize filter is different from `resize` method
*/
fastResize(options: FastResizeOptions): this
/**
* Performs a Gaussian blur on this image.

@@ -364,2 +438,4 @@ * `sigma` is a measure of how much to blur by.

crop(x: number, y: number, width: number, height: number): this
/** Overlay an image at a given coordinate (x, y) */
overlay(onTop: Buffer, x: number, y: number): this
/** Return this image's pixels as a native endian byte slice. */

@@ -366,0 +442,0 @@ rawPixels(signal?: AbortSignal | undefined | null): Promise<Buffer>

4

index.js

@@ -249,5 +249,7 @@ const { existsSync, readFileSync } = require('fs')

const { ChromaSubsampling, compressJpegSync, compressJpeg, CompressionType, FilterType, PngRowFilter, losslessCompressPngSync, losslessCompressPng, pngQuantizeSync, pngQuantize, Orientation, ResizeFilterType, JsColorType, Transformer } = nativeBinding
const { ChromaSubsampling, FastResizeFilter, ResizeFit, compressJpegSync, compressJpeg, CompressionType, FilterType, PngRowFilter, losslessCompressPngSync, losslessCompressPng, pngQuantizeSync, pngQuantize, Orientation, ResizeFilterType, JsColorType, Transformer } = nativeBinding
module.exports.ChromaSubsampling = ChromaSubsampling
module.exports.FastResizeFilter = FastResizeFilter
module.exports.ResizeFit = ResizeFit
module.exports.compressJpegSync = compressJpegSync

@@ -254,0 +256,0 @@ module.exports.compressJpeg = compressJpeg

{
"name": "@napi-rs/image",
"version": "1.4.4",
"version": "1.5.0",
"main": "index.js",

@@ -64,19 +64,19 @@ "types": "index.d.ts",

"devDependencies": {
"@napi-rs/cli": "^2.14.1"
"@napi-rs/cli": "^2.14.3"
},
"gitHead": "fdd80a15bf0f215383c622a4361a3b74dd22bddd",
"gitHead": "c111cd9d79b36943b3c082fabc3510ca9e4f5645",
"optionalDependencies": {
"@napi-rs/image-win32-x64-msvc": "1.4.4",
"@napi-rs/image-darwin-x64": "1.4.4",
"@napi-rs/image-linux-x64-gnu": "1.4.4",
"@napi-rs/image-darwin-arm64": "1.4.4",
"@napi-rs/image-android-arm64": "1.4.4",
"@napi-rs/image-linux-arm64-gnu": "1.4.4",
"@napi-rs/image-linux-arm64-musl": "1.4.4",
"@napi-rs/image-linux-arm-gnueabihf": "1.4.4",
"@napi-rs/image-linux-x64-musl": "1.4.4",
"@napi-rs/image-freebsd-x64": "1.4.4",
"@napi-rs/image-win32-ia32-msvc": "1.4.4",
"@napi-rs/image-android-arm-eabi": "1.4.4"
"@napi-rs/image-win32-x64-msvc": "1.5.0",
"@napi-rs/image-darwin-x64": "1.5.0",
"@napi-rs/image-linux-x64-gnu": "1.5.0",
"@napi-rs/image-darwin-arm64": "1.5.0",
"@napi-rs/image-android-arm64": "1.5.0",
"@napi-rs/image-linux-arm64-gnu": "1.5.0",
"@napi-rs/image-linux-arm64-musl": "1.5.0",
"@napi-rs/image-linux-arm-gnueabihf": "1.5.0",
"@napi-rs/image-linux-x64-musl": "1.5.0",
"@napi-rs/image-freebsd-x64": "1.5.0",
"@napi-rs/image-win32-ia32-msvc": "1.5.0",
"@napi-rs/image-android-arm-eabi": "1.5.0"
}
}

@@ -422,2 +422,24 @@ # `@napi-rs/image`

#### `overlay`
```ts
/**
* Overlay an image at a given coordinate (x, y)
*/
overlay(onTop: Buffer, x: number, y: number): this
```
```ts
import { writeFileSync } from 'fs'
import { Transformer } from '@napi-rs/image'
const imageOutputPng = await new Transformer(PNG).overlay(PNG, 200, 200).png()
writeFileSync(
'output-overlay-png.png',
imageOutputPng
)
```
**ResizeFilterType**:

@@ -424,0 +446,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc