Skip to content

Instantly share code, notes, and snippets.

View sudoaaditya's full-sized avatar

Aaditya Kashid sudoaaditya

View GitHub Profile
@sudoaaditya
sudoaaditya / App.css
Created February 2, 2021 09:32
ReactJS Image Crop
.imgcrop__mainDiv{
display: flex;
flex-direction: column;
align-items: center;
margin: 30px;
};
.imgcrop__header {
position: relative;
@sudoaaditya
sudoaaditya / ImageFunctions.js
Created February 2, 2021 09:14
ReactJS Image Crop
const downloadBase64File = (base64Data, filename) => {
// from raw data to Image!!
var element = document.createElement('a');
element.setAttribute('href', base64Data);
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
@sudoaaditya
sudoaaditya / App.js
Last active February 2, 2021 10:03
Image Crop using react-image-crop
import React, { Component } from 'react';
import "./App.css"
import ReactCrop from 'react-image-crop';
// This has to done as the image crop guide needs this css open to work! (They Did it Like That, UGHH!)
import 'react-image-crop/dist/ReactCrop.css';
/* Import Image Functions Here */
import {
base64StringtoFile,
extractImageFileExtensionFromBase64,
@sudoaaditya
sudoaaditya / index.js
Last active February 2, 2021 07:35
React Image Crop Code
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App />,
document.getElementById('root')
);