Skip to content
This repository was archived by the owner on Oct 18, 2024. It is now read-only.

compress and resize image before uploading via browser and transform to base64

Notifications You must be signed in to change notification settings

hannanstd/js-client-image-compress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

js-client-image-compress

Compress and Resize images via browser and transform it to base64.

when i was working on a project, i saw that when i pick some images via fileInput, that image will rotate automatically!
after searching i understood that occures due to EXIF Orientation values.

https://sirv.com/help/resources/rotate-photos-to-be-upright/

finaly i found a function that recognize the EXIF Orientation value.

i combined this function to other functions that does below:

1 - Recognizes EXIF Orientation value.
2 - Fixes Orientation to Original.
3 - Compresses image file size.
4 - Resizes Width & Height
5 - Delivers image as Base64

How to use:

// <input type="file" id='image-picker'/>

document.getElementById('image-picker').onchange = function() {
    var file = this.files[0];
    proccessImage(file, {
        max_width: 1000,
        max_height: 1000,
        percent: 0.7, // percent of compress
      }, function (base64) {
        console.log(base64); // get output image as base64
      }
    );
};

About

compress and resize image before uploading via browser and transform to base64

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy