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

@alttiri/get-image-data

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alttiri/get-image-data - npm Package Compare versions

Comparing version 0.0.2-20241214 to 0.0.3-20241215

2

package.json
{
"name": "@alttiri/get-image-data",
"version": "0.0.2-20241214",
"version": "0.0.3-20241215",
"description": "A simple library to get ImageData on Node.js and browsers",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/AlttiRi/get-image-data",

@@ -5,6 +5,18 @@ # get-image-data

- In Node.js use `getImageDataWithCanvas` to get `ImageData` with `sharp` library.
```bash
npm i @alttiri/get-image-data
```
_Do not forget to install `sharp`. It's not included as a dependency._
---
- For browsers use `getImageDataWithCanvas`. It uses `OffscreenCanvas` to get the `ImageData` for `File`/`Blob` input.
- In Node.js use [`getImageDataWithSharp`](https://github.com/AlttiRi/get-image-data/blob/master/src/get-with-sharp.ts) to get `ImageData` with `sharp` library.
_Do not forget to install [`sharp`](https://www.npmjs.com/package/sharp) (`npm i sharp`). It's not included as a dependency._
```bash
npm i @alttiri/get-image-data sharp
```
- For browsers just use [`getImageDataWithCanvas`](https://github.com/AlttiRi/get-image-data/blob/master/src/get-with-canvas.ts).
It uses `OffscreenCanvas` to get the `ImageData` for `File`/`Blob` input.
import { ImageDataLike } from "./types.js";
export declare function getImageDataWithSharp(imagePath: string): Promise<ImageDataLike>;
export declare function getImageDataWithSharp(inputData: string | ArrayBufferLike, longPathFix?: boolean): Promise<ImageDataLike>;

@@ -0,3 +1,4 @@

import path from "node:path";
let sharpCache;
export async function getImageDataWithSharp(imagePath) {
export async function getImageDataWithSharp(inputData, longPathFix = true) {
if (!sharpCache) {

@@ -7,4 +8,7 @@ const sharpModule = await import("sharp");

}
if (longPathFix && typeof inputData === "string") {
inputData = path.toNamespacedPath(inputData);
}
const sharp = sharpCache;
const imageData = await sharp(imagePath)
const imageData = await sharp(inputData)
.ensureAlpha()

@@ -11,0 +15,0 @@ .raw()

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