Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

image-in-browser

yegor-pelykh1.2kMIT3.2.3TypeScript support: included

Package for encoding / decoding images, transforming images, applying filters, drawing primitives on images on the client side (no need for server Node.js)

convert, converter, browser, encode, decode, image, animation, bmp, gif, ico, jpg, jpeg, png, pnm, pbm, pgm, ppm, psd, pvr, tga, tif, tiff, webp, color, pixel, contrast, saturation, brightness, gamma, exposure, hue, adjust-color, billboard, bleach-bypass, bulge-distortion, bump, chromatic-aberration, color-halftone, color-offset, convolution, dither, drop-shadow, edge-glow, emboss, gaussian-blur, grayscale, hexagon-pixelate, invert, luminance-threshold, monochrome, noise, normalize, pixelate, quantize, reinhard-tone-map, sepia, sketch, smooth, sobel, solarize, stretch-ditortion, vignette, circle, line, polygon, rect, fill, composite, crop, crop-circle, flip, rectify, resize, rotate, flip, flip-horizontal, flip-vertical, trim

readme

📋 Table of Contents

🌟 Introduction

Welcome to image-in-browser! This powerful NPM package allows you to effortlessly load, manipulate, and save images in a variety of formats, all within your browser or Node.js environment—no server-side setup required!

Key Features:

  • Fully compatible with both Node.js and browser environments
  • Developed entirely in TypeScript, compiled to JavaScript
  • No external dependencies — lightweight and efficient
  • A modern ES (ECMAScript) module for seamless integration

Whether you're working with static images or animated graphics, this library is perfect for projects where you want to keep your code isolated from the underlying system.

🖼️ Supported Image Formats

image-in-browser supports a wide range of image formats for both reading and writing:

Read / Write Formats:

  • BMP
  • GIF (including animated GIFs)
  • ICO
  • JPG
  • PNG (including animated APNG)
  • TGA
  • PVR
  • TIFF

Read Only Formats:

  • PNM (PBM, PGM, PPM)
  • PSD
  • WEBP (including animated WEBP)

Write Only Format:

  • CUR

💡 Usage Examples

Want to see image-in-browser in action? Check out our dedicated repository for practical examples and code snippets:

image-in-browser.examples (GitHub)

This repository will continue to grow, providing you with more examples over time.

📚 Documentation

For comprehensive documentation on how to use the package, please visit our Wiki.

⚙️ Performance Considerations

Please note that while image-in-browser is a versatile library, its performance may not match that of native libraries, as it is entirely written in TypeScript. Keep this in mind when planning your projects.

🧪 Testing

The project includes a comprehensive suite of tests to ensure functionality and reliability. To run the tests, use the following command:

npm run test:all

This will execute all test cases defined in the project.

🤝 Contributing

We believe that contributions are the heart of the open-source community! Your input can help make image-in-browser even better.

To contribute:

  1. Fork the project
  2. Create your feature branch (e.g., git checkout -b feature/AmazingFeature)
  3. Important! Run npm run build to ensure your code meets project standards
  4. Important! Address any errors or warnings that arise from your changes
  5. Commit your changes (e.g., git commit -m 'Add some AmazingFeature')
  6. Push to your branch (e.g., git push origin feature/AmazingFeature)
  7. Open a Pull Request

Your support is greatly appreciated!

📜 License

This project is licensed under the MIT License. See the LICENSE.md file for details.

🔗 Useful Links

Check out our NPM repository for more information:

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by auto-changelog.

v3.2.2

  • chore: Upgraded dependency versions a7d4bcb
  • feat: Add resize transform function for in-place resizing d24099c
  • test: Added execution timeout for all tests equal to 30 seconds ceab2f2

v3.2.1

1 November 2024

  • chore: Upgraded dependency versions a078540
  • fix: Fixes to BMP-encoding for uint1 images and images without palette 2ac80f3
  • chore: Release v3.2.1 574e441

v3.2.0

11 September 2024

  • chore: Upgraded dependency versions b9dc526
  • feat: Implement physical pixel size management for PNG 07deebf
  • style: More correct condition in drawLine 3d1e139

v3.1.0

15 July 2024

  • style: Comments of encoding functions have been normalized 35f7663
  • feat: Added the ability to skip EXIF data during image encoding 661552d
  • chore: Release v3.1.0 79d8e5e

v3.0.0

28 June 2024

  • style: Standardization of function signatures, all important parts are covered by JSDoc comments 58da314
  • refactor: Translation of the part responsible for packing and unpacking content into Typescript with full documentation of its functions 9f32ea1
  • chore: Upgraded dependency versions 94baf67

v2.7.1

17 May 2024

  • style: Clarification of decode information types for PNG, PNM and PVR formats e80c656
  • feat: EXIF reading support for WebP e029885
  • test: Test for decoding EXIF from WebP a672ccf

v2.7.0

15 May 2024

  • chore: package-lock.json updated 12eaaa8
  • fix: Imports / exports have been normalized across the entire code base 9b2b439
  • feat: The UZIP dependency has been replaced with an internal UZIP implementation 0adf3d0

v2.6.0

14 May 2024

  • fix: Auto conversion of images with palette in Filter functions 1231f41
  • fix: Fixed ditherImage filter 90578df
  • feat: BinaryQuantizer added 1513fc2

v2.5.0

10 May 2024

  • feat: Support for Photoshop PSD format (read-only) b5b0b95
  • feat: Support for PVR (PVRTC) format 607951b
  • chore: Updated dependencies 5236cce

v2.4.1

8 May 2024

  • fix: Fix of APNG image decoding 79f22e0
  • chore: Release v2.4.1 2de5144
  • fix: Fix of drawPixel() method 9e32ba7

v2.4.0

13 April 2024

  • chore: Updated dependencies bff377d
  • feat: Add support for uint16 palette images 63b9caf
  • feat: Added Solarize filter ea024cd

v2.3.0

26 March 2024

  • feat: Added PNM decoder 4788f19
  • test: Added tests for using PNM decoder 2f6c4d5
  • chore: Release v2.3.0 5bfdca1

v2.2.0

5 February 2024

  • chore: Updated dependencies d61a809
  • feat: MemoryImage.getBytes should convert image if order has different number of channels fbeb46b
  • test: Improving tests 8e8ca90

v2.1.3

12 January 2024

v2.1.2

12 January 2024

  • chore: Release v2.1.2 aa52c95
  • style: Comments updated for MemoryImage.fromBytes adccf8e
  • fix: Mitigate bad IFD offset e099060

v2.1.1

22 October 2023

  • chore: Release v2.1.1 95bbf2b
  • feat: Added the ability to decode the largest icon frame d8a4884

v2.1.0

22 October 2023

  • feat: Added functions for encoding and decoding images by their MIME type (IANA media type) 2a3526e
  • chore: Release v2.1.0 3d102c0

v2.0.1

15 October 2023

v2.0.0

15 October 2023

  • feat: Added support for decoding WebP format 848cd5b
  • feat: InputBuffer improvements cd23324
  • fix: Refactoring the use of bitwise right shift 0444673

v1.7.0

7 October 2023

  • chore: Update dependencies ad1da35
  • feat: New maintainAspect and backgroundColor options for copyResize b3649d6
  • fix: Clamp pixel colors when using a noise filter 62353fe

v1.6.3

14 August 2023

  • chore: Release v1.6.3 9cef4dd
  • style: Minor code style improvement 06b1283
  • fix: No need to clamp brightness for adjustColor filter ca5925d

v1.6.2

22 July 2023

  • test: Tests for copyExpandCanvas transformation f3ba156
  • feat: A new kind of transformation - copyExpandCanvas b3e97c7
  • chore: Release v1.6.2 fc811d6

v1.6.1

27 June 2023

  • chore: Update dependencies 919a414
  • chore: Release v1.6.1 ef680c0
  • perf: Performance optimization for BmpEncoder 46d6857

v1.6.0

23 May 2023

  • chore: Updated dependencies 5d50ff9
  • feat: Add 4:2:0 chroma subsampling format in JpegEncoder dc3226e
  • refactor: Refactoring of Encoder.encode and Decoder.decode method parameters 4a8f215

v1.5.2

10 April 2023

  • chore: Fix of using release-it instead of standard-version 85583b9
  • chore: Removing an ugly Сhangelog 1e75f92
  • chore: Release v1.5.2 8739711

v1.5.1

10 April 2023

  • chore: Removed compact version 6c49057
  • chore: Updated dependencies 1c8f872
  • feat: Added the ability to iterate over ifd entries d3d213c

v1.4.7

11 February 2023

  • chore: Many fundamental changes in the project 406e0a2
  • Many fundamental changes in the project 20b40d8
  • chore: Compact version built b50f304

v1.4.6

13 December 2022

  • refactor: reading / writing / editing of exif data 7a870b1
  • test: Tests for new approach of managing EXIF data 78d1131
  • style: Improved imports in test files c0cee43

v1.4.5

26 November 2022

  • Added support for monochrome (1 bit per pixel) format for use on thermal printers 40bfd2f
  • chore(release): 1.4.5 4877eda

v1.4.4

5 November 2022

v1.4.3

3 November 2022

  • chore(release): 1.4.3 4def084
  • chore: Updated description in package.json 239d2ff

v1.4.2

3 November 2022

v1.4.1

3 November 2022

  • refactor: Removed ColorUtils class, all functions moved to Color class 00b4941
  • docs: Supportable documentation (README) has been created 8699fa3
  • chore: Compact version built 87dfbf4

v1.4.0

2 November 2022

  • feat: Added various image filters 0095758
  • chore: Compact version built 75a5fe9
  • test: Test procedures for testing image filters f579d29

v1.3.0

1 November 2022

  • feat: Refactoring of existing image transformation functions, various new transformation functions have been added 7caa9a1
  • feat: New version of drawing functions 0193cd1
  • test: Added tests for drawing functions 8c9679c

v1.2.1

29 October 2022

  • chore: Compact version built 9f98596
  • chore: Updated keywords in package.json 2df2859
  • chore(release): 1.2.1 2b7d1bf

v1.2.0

29 October 2022

  • feat: Added support for encoding and decoding TIFF format 6c1b408
  • test: Added tests to check encoding and decoding of TIFF images d78b9a1
  • style: Improved some things related to the visibility of class parts 72fdf98

v1.1.0

25 October 2022

  • feat: Added support for a TGA image format 1b7fb6a
  • refactor: Removed unnecessary methods from the index file 7dfa843
  • chore: Compact version built 1f949f2

v1.0.8

23 October 2022

  • chore: Updated dependencies ae50b9a
  • fix: Fix transparency issue with animated GIF images, fixes for APNG, other fixes for correct work a399e1e
  • chore(release): 1.0.8 67043ae

v1.0.7

13 October 2022

  • chore(release): 1.0.7 044ac6b
  • chore: Compact version built 9405c6a
  • fix: Fix of wrong height in IcoBmpInfo 03a5a5c

v1.0.6

10 October 2022

  • perf: Getting rid of unnecessary dependency on the "buffer" package 126e5f3
  • chore: Compact version built 09fa674
  • chore(release): 1.0.6 5adbf6b

v1.0.5

9 October 2022

  • chore(release): 1.0.5 3817203
  • chore: Compact version built 8d8bc2a
  • build: Switched compiler target to ESNext to impove stability and compatibility a43e4fa

v1.0.4

9 October 2022

  • chore: Compact version built e81be0d
  • build: Added the ability to build a package as a compact file. 2295c30
  • chore(release): 1.0.4 16fdae8

v1.0.3

9 October 2022

  • fix: Added missing exports of various types 191507e
  • chore(release): 1.0.3 1e904a1

v1.0.2

9 October 2022

  • fix: Fixed problems with using typings 7a2e220
  • chore(release): 1.0.2 a3c9d36

v1.0.1

8 October 2022

  • build: Added standard-version package as the dev. dependency eb9be9a
  • chore(release): 1.0.1 8999c6a
  • fix: Fixed a wrong build that made it impossible to use the package 18b1234

v1.0.0

8 October 2022