-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #67 from mis94/orientation-change
Added a capability to rotate Thumbnail images according to exif orientation property.
- Loading branch information
Showing
3 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import Gallery from '../src/Gallery'; | ||
|
||
|
||
class DifferentOrientationsExample extends React.Component { | ||
constructor(props){ | ||
super(props); | ||
|
||
this.state = { | ||
images: this.props.images | ||
}; | ||
|
||
} | ||
|
||
render () { | ||
return ( | ||
<div style={{ | ||
display: "block", | ||
minHeight: "1px", | ||
width: "100%", | ||
border: "1px solid #ddd", | ||
overflow: "auto"}}> | ||
<Gallery | ||
images={this.state.images} | ||
/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
DifferentOrientationsExample.propTypes = { | ||
images: PropTypes.arrayOf( | ||
PropTypes.shape({ | ||
src: PropTypes.string.isRequired, | ||
thumbnail: PropTypes.string.isRequired, | ||
thumbnailWidth: PropTypes.number.isRequired, | ||
thumbnailHeight: PropTypes.number.isRequired, | ||
orientation: PropTypes.number | ||
}) | ||
).isRequired | ||
}; | ||
|
||
DifferentOrientationsExample.defaultProps = { | ||
images: shuffleArray([ | ||
{ | ||
src: "https://c5.staticflickr.com/9/8768/28941110956_b05ab588c1_b.jpg", | ||
thumbnail: "https://c5.staticflickr.com/9/8768/28941110956_b05ab588c1_n.jpg", | ||
thumbnailWidth: 240, | ||
thumbnailHeight: 320, | ||
orientation: 1 /* the orientation of the image can be extracted from exif orientation property | ||
'exif.Orientation'. This can be done using libraries like 'lodash', lodash has a method '_get' | ||
that can be used as follows: | ||
orientation = _get(imageObject, 'exif.Orientation', 1); | ||
*/ | ||
}, | ||
{ | ||
src: "https://c3.staticflickr.com/9/8583/28354353794_9f2d08d8c0_b.jpg", | ||
thumbnail: "https://c3.staticflickr.com/9/8583/28354353794_9f2d08d8c0_n.jpg", | ||
thumbnailWidth: 320, | ||
thumbnailHeight: 190, | ||
orientation: 6 | ||
}, | ||
{ | ||
src: "https://c7.staticflickr.com/9/8569/28941134686_d57273d933_b.jpg", | ||
thumbnail: "https://c7.staticflickr.com/9/8569/28941134686_d57273d933_n.jpg", | ||
thumbnailWidth: 320, | ||
thumbnailHeight: 148, | ||
orientation: 3 | ||
}, | ||
{ | ||
src: "https://c6.staticflickr.com/9/8342/28897193381_800db6419e_b.jpg", | ||
thumbnail: "https://c6.staticflickr.com/9/8342/28897193381_800db6419e_n.jpg", | ||
thumbnailWidth: 320, | ||
thumbnailHeight: 213, | ||
orientation: 8 | ||
}, | ||
{ | ||
src: "https://c2.staticflickr.com/9/8239/28897202241_1497bec71a_b.jpg", | ||
thumbnail: "https://c2.staticflickr.com/9/8239/28897202241_1497bec71a_n.jpg", | ||
thumbnailWidth: 248, | ||
thumbnailHeight: 320 | ||
} | ||
]) | ||
}; | ||
|
||
ReactDOM.render(<DifferentOrientationsExample />, document.getElementById('differentOrientationsExample')); |
This file contains 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