Skip to content

Instantly share code, notes, and snippets.

@dprabu17
Forked from ospfranco/ImageViewer.tsx
Created May 29, 2019 09:59
Show Gist options
  • Save dprabu17/93a9eb27679f27f41fcc6e159dba5d98 to your computer and use it in GitHub Desktop.
Save dprabu17/93a9eb27679f27f41fcc6e159dba5d98 to your computer and use it in GitHub Desktop.
Component that correctly rotates an image based on EXIF data
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