Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

image-resizor

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-resizor

Effortlessly convert, resize, and compress images (jpg, png, heic, heif, webp) into optimized png and jpg formats, all within the browser environment.

latest
npmnpm
Version
1.1.3
Version published
Weekly downloads
32
-36%
Maintainers
1
Weekly downloads
 
Created
Source

image-resizor

Effortlessly convert, resize, and compress images (jpg, png, heic, heif, webp) into optimized png and jpg formats, all within the browser environment.

Demo

https://namti.github.io/image-resizor

Usage

import ImageResizor from 'image-resizor';
<script src="https://cdn.jsdelivr.net/npm/image-resizor/dist/image-resizor.iife.js"></script>
new ImageResizor(file, {
  maxWidth: 300,
  maxHeight: 300,
  outputType: 'image/jpeg',
  quality: .8,
})
  .init()
  .then(instance => console.log(instance.toDataURL()))
  .catch(e => console.error(e));

Arguments

new ImageResizor(file[, { ...options }])

file

File | Blob

options

KeyTypeDefaultOptions
maxWidthnumber2000
maxHeightnumber2000
scalenumber10.1~1
outputTypestringimage/png"image/png" | "image/jpeg"
backgroundColorstring#ffffffBackground fill for converting images with alpha channel to "image/jpeg"
qualitynumber0.90.1~1 Available if the outputType is "image/jpeg"

Methods

toDataURL()

Converts the image into a data URL.

instance.toDataURL(): string | undefined

toBlob()

Converts the image into a Blob.

instance.toBlob(): Promise<Blob>

getSupportedTypes()

enum ImageType {
  jpg = 'image/jpeg',
  jpeg = 'image/jpeg',
  png = 'image/png',
  heic = 'image/heic',
  heif = 'image/heif',
  webp = 'image/webp',
}
static getSupportedTypes(): typeof ImageType 

Keywords

photo

FAQs

Package last updated on 15 May 2024

Did you know?

Socket

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.

Install

Related posts