
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
js-image-lib
Advanced tools
An image manipulation library using only pure JavaScript
This library lets you:
png
, jpeg
, gif
, bmp
, and tiff
crop
, rotate
, blur
, and flip
This library uses pure browser-compatible JavaScript, relying on no Node packages. This means js-image-lib can be run anywhere you use JavaScript!
Note: The use of pure JavaScript means this library will run much slower than alternative libraries that have C/etc bindings. You should primarily use js-image-lib in environments where speed is not the first concern, especially in cases where you are trying to support all platforms!
To install this library, use on of the following commands:
npm install -S js-image-lib
yarn add js-image-lib
Retrieve your image as a Uint8Array, then transform it with imageTransformer
by providing the image and the options to use.
import { imageTransformer, MimeType } from "js-image-lib";
const image: Uint8Array = ...;
const contentType: MimeType = ...;
const transformOptions = {
width: 100,
};
const newImage = imageTransformer({
data: image,
contentType
}, transformOptions);
Note: The parameter contentType
is optional, but should be provided if it is known to speed up performance.
export interface TransformOptions {
/** Width of resulting image. */
width: number;
/** Height of resulting image. If width is present, this take priority. */
height?: number;
/** The content type of the resulting image. (optional, default source type) */
contentType?: MimeType;
/** How the image should be resized to fit both provided dimensions. (optional, default 'contain') */
fit?: ImageFit;
/** Position to use when fit is cover or contain. (optional, default 'center') */
position?: ImagePosition;
/** Background color of resulting image. (optional, default [0x00, 0x00, 0x00, 0x00]) */
background?: Color;
/** Quality, integer 1-100. (optional, default 80) */
quality?: number;
/** zlib compression level, 0-9. (optional, default 9) */
compressionLevel?: number;
/** Number of animation iterations, use 0 for infinite animation. (optional, default 0) */
loop?: number;
/** Delay between animation frames (in milliseconds). (optional, default 100) */
delay?: number;
/** The number of pixels to blur the image by. (optional, default null) */
blurRadius?: number | null;
/** The number of degrees to rotate the image by. (optional, default null) */
rotate?: number | null;
/** The direction to mirror the image by. (optional, default null) */
flip?: FlipDirection | null;
/** The location to crop the source image before any other operations are applied. (optional, default null) */
crop?: CropOptions | null;
}
[0.2.0] - 2022-06-21
ImagePosition
to string union with additional optionsImageFit
and FlipDirection
types to string unions to match ImagePosition
FAQs
An image manipulation library using only pure JavaScript
The npm package js-image-lib receives a total of 317 weekly downloads. As such, js-image-lib popularity was classified as not popular.
We found that js-image-lib demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.