onurzorluer / React Image File Resizer
Licence: mit
Resize Local Images with React 🌄 🌅
Stars: ✭ 108
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to React Image File Resizer
Lipo
👄 Free image manipulation API service built on top of Sharp (an alternative to Jimp, Graphics Magic, Image Magick, and PhantomJS)
Stars: ✭ 101 (-6.48%)
Mutual labels: image, resize
File Upload With Preview
🖼 A simple file-upload utility that shows a preview of the uploaded image. Written in pure JavaScript. No dependencies. Works well with Bootstrap 4 or without a framework.
Stars: ✭ 352 (+225.93%)
Mutual labels: image, file
Compresshelper
🔥 压缩文件,压缩图片,压缩Bitmap,Compress, CompressImage, CompressFile, CompressBitmap:https://github.com/nanchen2251/AiYaCompressHelper
Stars: ✭ 2,362 (+2087.04%)
Mutual labels: image, file
Docker Nginx Image Proxy
on the fly image cropping with gravity, resize and compression microservice
Stars: ✭ 79 (-26.85%)
Mutual labels: image, resize
Pica
Resize image in browser with high quality and high speed
Stars: ✭ 2,900 (+2585.19%)
Mutual labels: image, resize
Sharp
High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
Stars: ✭ 21,131 (+19465.74%)
Mutual labels: image, resize
Bimg
Go package for fast high-level image processing powered by libvips C library
Stars: ✭ 1,394 (+1190.74%)
Mutual labels: image, resize
Nova Advanced Image Field
🌄📐 A Laravel Nova advanced image field with cropping and resizing using Cropper.js and Intervention Image
Stars: ✭ 67 (-37.96%)
Mutual labels: image, resize
Uploadcare Widget
Uploadcare Widget, an ultimate tool for HTML5 file upload supporting multiple file upload, drag&drop, validation by file size/file extension/MIME file type, progress bar for file uploads, image preview.
Stars: ✭ 183 (+69.44%)
Mutual labels: image, file
Angular File Uploader
Angular file uploader is an Angular 2/4/5/6/7/8/9/10 + file uploader module with Real-Time Progress Bar, Responsive design, Angular Universal Compatibility, localization and multiple themes which includes Drag and Drop and much more.
Stars: ✭ 92 (-14.81%)
Mutual labels: image, file
Isobmff
C++ Library for ISO/IEC 14496-12 - ISO Base Media File Format (QuickTime, MPEG-4, HEIF, etc)
Stars: ✭ 157 (+45.37%)
Mutual labels: image, file
Tableexport
tableExport(table导出文件,支持json、csv、txt、xml、word、excel、image、pdf)
Stars: ✭ 261 (+141.67%)
Mutual labels: image, file
Imaging
Imaging is a simple image processing package for Go
Stars: ✭ 4,023 (+3625%)
Mutual labels: image, resize
Mergi
go library for image programming (merge, crop, resize, watermark, animate, ease, transit)
Stars: ✭ 127 (+17.59%)
Mutual labels: image, resize
Hrconvert2
A self-hosted, drag-and-drop, & nosql file conversion server that supports 62x file formats.
Stars: ✭ 132 (+22.22%)
Mutual labels: image, file
Eager Image Loader
The eager-loading for image files on the web page that loads the files according to your plan. This differs from the lazy-loading, for example, this can be used to avoid that the user waits for the loading.
Stars: ✭ 22 (-79.63%)
Mutual labels: image, file
Ffimageloading
Image loading, caching & transforming library for Xamarin and Windows
Stars: ✭ 1,288 (+1092.59%)
Mutual labels: image, resize
React Image File Resizer
react-image-file-resizer
is a react module that can rescaled local images.
- You can change image's width, height, format, rotation and quality.
- It returns resized image's new base64 URI or Blob. The URI can be used as the source of an
<Image>
component.
Setup
Install the package:
npm i react-image-file-resizer
or
yarn add react-image-file-resizer
Usage
import Resizer from 'react-image-file-resizer';
Resizer.imageFileResizer(
file, // Is the file of the image which will resized.
maxWidth, // Is the maxWidth of the resized new image.
maxHeight, // Is the maxHeight of the resized new image.
compressFormat, // Is the compressFormat of the resized new image.
quality, // Is the quality of the resized new image.
rotation, // Is the degree of clockwise rotation to apply to uploaded image.
responseUriFunc, // Is the callBack function of the resized new image URI.
outputType, // Is the output type of the resized new image.
minWidth, // Is the minWidth of the resized new image.
minHeight, // Is the minHeight of the resized new image.
);
Example 1
First, wrap this resizer:
const resizeFile = (file) => new Promise(resolve => {
Resizer.imageFileResizer(file, 300, 300, 'JPEG', 100, 0,
uri => {
resolve(uri);
},
'base64'
);
});
And then use it in your async function:
const onChange = async (event) => {
try {
const file = event.target.files[0];
const image = await resizeFile(file);
console.log(image);
} catch(err) {
console.log(err);
}
}
Example 2
import React, { Component } from 'react';
import Resizer from 'react-image-file-resizer';
class App extends Component {
constructor(props) {
super(props);
this.fileChangedHandler = this.fileChangedHandler.bind(this);
this.state = {
newImage: ''
}
}
fileChangedHandler(event) {
var fileInput = false
if(event.target.files[0]) {
fileInput = true
}
if(fileInput) {
try {
Resizer.imageFileResizer(
event.target.files[0],
300,
300,
'JPEG',
100,
0,
uri => {
console.log(uri)
this.setState({ newImage: uri })
},
'base64',
200,
200,
);
} catch(err) {
console.log(err)
}
}
}
render() {
return (
<div className="App">
<input type="file" onChange={this.fileChangedHandler}/>
<img src={this.state.newImage} alt=''/>
</div>
);
}
}
export default App;
Option | Description | Type | Required |
---|---|---|---|
file |
Path of image file | object |
Yes |
maxWidth |
New image max width (ratio is preserved) | number |
Yes |
maxHeight |
New image max height (ratio is preserved) | number |
Yes |
compressFormat |
Can be either JPEG, PNG or WEBP. | string |
Yes |
quality |
A number between 0 and 100. Used for the JPEG compression.(if no compress is needed, just set it to 100) | number |
Yes |
rotation |
Degree of clockwise rotation to apply to the image. Rotation is limited to multiples of 90 degrees.(if no rotation is needed, just set it to 0) (0, 90, 180, 270, 360) | number |
Yes |
responseUriFunc |
Callback function of URI. Returns URI of resized image's base64 format. ex: uri => {console.log(uri)});
|
function |
Yes |
outputType |
Can be either base64, blob or file.(Default type is base64) | string |
No |
minWidth |
New image min width (ratio is preserved, defaults to null) | number |
No |
minHeight |
New image min height (ratio is preserved, defaults to null) | number |
No |
License
Contributors
Thanks goes to these wonderful people (emoji key):
🚧 | 🚧 | 🚧 |
Shubham Zanwar 📖 |
🚧 | 🚧 | 🚧 |
This project follows the all-contributors specification. Contributions of any kind welcome!
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].