@uploadcare/image-shrink is a browser-based image compression library that shrinks images to a target resolution while preserving aspect ratios, EXIF metadata, and ICC color profiles. Outputs JPEG with configurable quality and automatically switches to PNG for images with transparency. Uses native canvas scaling with intelligent multi-pass fallback for iOS. Designed for pre-upload image optimization in web applications. See docs here.
npm install @uploadcare/image-shrink
import { shrinkFile } from '@uploadcare/image-shrink'
const shrinkedBlob = shrinkImage(blob, {
size: number,
quality?: number
})
If you think you ran into something in Uploadcare libraries that might have security implications, please hit us up at bugbounty@uploadcare.com or Hackerone.
We'll contact you personally in a short time to fix an issue through co-op and prior to any public disclosure.
Issues and PRs are welcome. You can provide your feedback or drop us a support request at hello@uploadcare.com.