https://github.com/arjun-g/blob-image-convert
Convert image Blob and File to different formats (png, webp and jpeg)
https://github.com/arjun-g/blob-image-convert
Last synced: 5 months ago
JSON representation
Convert image Blob and File to different formats (png, webp and jpeg)
- Host: GitHub
- URL: https://github.com/arjun-g/blob-image-convert
- Owner: arjun-g
- License: mit
- Created: 2017-02-21T10:53:02.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-09T13:02:34.000Z (about 8 years ago)
- Last Synced: 2024-11-10T20:20:55.495Z (6 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 10
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Blob Image Convert
Convert image Blob or File object to different formats (png, webp and jpeg)## toPNG (convert blob to PNG)
Convert image blob to PNG blob## toJPEG (convert blob to JPEG)
Convert image blob to JPEG blob## toWebP (convert blob to WebP) - Works only on chrome, falls back to png
Convert image blob to WebP blob## Usage
Either use the callback or as a Promise
```javascript
blob.ToPNG(function(pngBlob){
})blob.ToPNG(pngBlob = >{
})blob.ToPNG().then(function(pngBlob) {
})
blob.ToPNG().then(pngBlob => {
})
```## How it works
The source blog image is drawn on a canvas object and then toDataURL method of canvas to convert to different file type.