New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@napi-rs/canvas

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@napi-rs/canvas - npm Package Compare versions

Comparing version 0.1.11 to 0.1.12

6

CHANGELOG.md

@@ -0,1 +1,7 @@

## [0.1.12](https://github.com/Brooooooklyn/canvas/compare/v0.1.11...v0.1.12) (2021-10-15)
### Features
- support avif format output ([f35b6ff](https://github.com/Brooooooklyn/canvas/commit/f35b6ffc28b40147b97244526f25173292453db8))
## [0.1.11](https://github.com/Brooooooklyn/canvas/compare/v0.1.10...v0.1.11) (2021-09-30)

@@ -2,0 +8,0 @@

15

index.d.ts

@@ -299,2 +299,9 @@ export interface DOMMatrix2DInit {

export interface AvifConfig {
quality?: number
alphaQuality?: number
speed?: number
threads?: number
}
export class Canvas {

@@ -308,6 +315,10 @@ constructor(width: number, height: number, flag?: SvgExportFlag)

encodeSync(format: 'png'): Buffer
encodeSync(format: 'avif', cfg?: AvifConfig): Buffer
encode(format: 'webp' | 'jpeg', quality?: number): Promise<Buffer>
encode(format: 'png'): Promise<Buffer>
encode(format: 'avif', cfg?: AvifConfig): Promise<Buffer>
toBuffer(mime: 'image/png' | 'image/jpeg' | 'image/webp'): Buffer
toBuffer(mime: 'image/png'): Buffer
toBuffer(mime: 'image/jpeg' | 'image/webp', quality?: number): Buffer
toBuffer(mime: 'image/avif', cfg?: AvifConfig): Buffer
// raw pixels

@@ -318,2 +329,3 @@ data(): Buffer

toDataURL(mime?: 'image/jpeg' | 'image/webp' | 'image/png', quality?: number): string
toDataURL(mime?: 'image/avif', cfg?: AvifConfig): string

@@ -323,2 +335,3 @@ toDataURLAsync(mime?: 'image/png'): Promise<string>

toDataURLAsync(mime?: 'image/jpeg' | 'image/webp' | 'image/png', quality?: number): Promise<string>
toDataURLAsync(mime?: 'image/avif', cfg?: AvifConfig): Promise<string>
}

@@ -325,0 +338,0 @@

@@ -216,2 +216,95 @@ const { platform, homedir } = require('os')

const {
encode: canvasEncode,
encodeSync: canvasEncodeSync,
toBuffer: canvasToBuffer,
toDataURL: canvasToDataURL,
toDataURLAsync: canvasToDataURLAsync,
} = Object.getPrototypeOf(canvasElement)
canvasElement.encode = function encode(type, qualityOrConfig) {
if (type === 'avif') {
return canvasEncode.call(
this,
type,
JSON.stringify({
quality: 92,
alphaQuality: 92,
threads: 0,
speed: 1,
...(qualityOrConfig || {}),
}),
)
}
return canvasEncode.call(this, type, qualityOrConfig || 92)
}
canvasElement.encodeSync = function encodeSync(type, qualityOrConfig) {
if (type === 'avif') {
return canvasEncodeSync.call(
this,
type,
JSON.stringify({
quality: 92,
alphaQuality: 92,
threads: 0,
speed: 1,
...(qualityOrConfig || {}),
}),
)
}
return canvasEncodeSync.call(this, type, qualityOrConfig || 92)
}
canvasElement.toBuffer = function toBuffer(type = 'image/png', qualityOrConfig) {
if (type === 'avif') {
return canvasToBuffer.call(
this,
type,
JSON.stringify({
quality: 92,
alphaQuality: 92,
threads: 0,
speed: 1,
...(qualityOrConfig || {}),
}),
)
}
return canvasToBuffer.call(this, type, qualityOrConfig || 92)
}
canvasElement.toDataURL = function toDataURL(type = 'image/png', qualityOrConfig) {
if (type === 'avif') {
return canvasToDataURL.call(
this,
type,
JSON.stringify({
quality: 92,
alphaQuality: 92,
threads: 0,
speed: 1,
...(qualityOrConfig || {}),
}),
)
}
return canvasToDataURL.call(this, type, qualityOrConfig || 92)
}
canvasElement.toDataURLAsync = function toDataURLAsync(type = 'image/png', qualityOrConfig) {
if (type === 'avif') {
return canvasToDataURLAsync.call(
this,
type,
JSON.stringify({
quality: 92,
alphaQuality: 92,
threads: 0,
speed: 1,
...(qualityOrConfig || {}),
}),
)
}
return canvasToDataURLAsync.call(this, type, qualityOrConfig || 92)
}
return canvasElement

@@ -218,0 +311,0 @@ }

26

package.json
{
"name": "@napi-rs/canvas",
"version": "0.1.11",
"version": "0.1.12",
"description": "Canvas for Node.js with skia backend",

@@ -73,4 +73,4 @@ "main": "index.js",

"@types/lodash": "^4.14.174",
"@typescript-eslint/eslint-plugin": "^4.31.2",
"@typescript-eslint/parser": "^4.31.2",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"ava": "^3.15.0",

@@ -123,3 +123,3 @@ "benny": "^3.6.15",

],
"timeout": "30s",
"timeout": "3m",
"environmentVariables": {

@@ -139,12 +139,12 @@ "SWC_NODE_PROJECT": "./tsconfig.json",

"optionalDependencies": {
"@napi-rs/canvas-win32-x64-msvc": "0.1.11",
"@napi-rs/canvas-darwin-x64": "0.1.11",
"@napi-rs/canvas-linux-x64-gnu": "0.1.11",
"@napi-rs/canvas-linux-arm-gnueabihf": "0.1.11",
"@napi-rs/canvas-linux-x64-musl": "0.1.11",
"@napi-rs/canvas-linux-arm64-gnu": "0.1.11",
"@napi-rs/canvas-linux-arm64-musl": "0.1.11",
"@napi-rs/canvas-darwin-arm64": "0.1.11",
"@napi-rs/canvas-android-arm64": "0.1.11"
"@napi-rs/canvas-win32-x64-msvc": "0.1.12",
"@napi-rs/canvas-darwin-x64": "0.1.12",
"@napi-rs/canvas-linux-x64-gnu": "0.1.12",
"@napi-rs/canvas-linux-arm-gnueabihf": "0.1.12",
"@napi-rs/canvas-linux-x64-musl": "0.1.12",
"@napi-rs/canvas-linux-arm64-gnu": "0.1.12",
"@napi-rs/canvas-linux-arm64-musl": "0.1.12",
"@napi-rs/canvas-darwin-arm64": "0.1.12",
"@napi-rs/canvas-android-arm64": "0.1.12"
}
}
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