-
-
Save dprabu17/93a9eb27679f27f41fcc6e159dba5d98 to your computer and use it in GitHub Desktop.
Component that correctly rotates an image based on EXIF data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import * as Reactdom from 'react-dom'; | |
import * as loadimage from 'blueimp-load-image'; | |
class ImageViewer extends React.Component<any, any> { | |
private imageCanvas; | |
public componentDidMount() { | |
loadimage('IMAGE_URL', (img) => { | |
img.className = 'fit_to_parent'; // css class: { max-width: 100%; max-height: 100%; } | |
Reactdom.findDOMNode(this.imageCanvas).appendChild(img); | |
}); | |
} | |
public render() { | |
return ( | |
<div | |
style={{width: '100%', height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center'}} | |
ref={(ref) => this.imageCanvas = ref} | |
/>); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment