Skip to content

Commit a5bd1e4

Browse files
committed
Add confirmation before converting really big images
1 parent 5a44be5 commit a5bd1e4

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ Well, it just puts the image in a canvas, calculates an array with the rgb value
1313
## Why?
1414
Hum... to demonstrate the power of CSS!
1515

16-
And this may have another interesting properties, like creating loading screens with pixel art.
16+
And this may have other interesting properties, like creating loading screens with pixel art or pixel-level animation.
1717

1818
## Planned features
1919
* Make the result smaller with smarter shadows and common background detection. (In progress)
2020
* Make animation and image morphing by using css transitions on the shadows. (In progress)
2121
* Add scale options to better suport pixel art.
22-
* Support for custom image filters.
22+
* Support for custom image filters.
23+
24+
## Development
25+
Run development server:
26+
npm start

src/App.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ export const App = React.createClass({
4747
fr.onload = (data) => {
4848
const base64 = data.currentTarget.result
4949

50+
if (base64.length > 100000) {
51+
let confirmation = confirm('Your image is really big, do you really want to try to convert it?')
52+
53+
if(!confirmation) {
54+
this.setState({
55+
loadingImage: false
56+
})
57+
return
58+
}
59+
}
60+
5061
base64ImageToRGBArray(base64, (err, data) => {
5162
if (err) return console.error(err)
5263

src/lib/base64ImageToRGBArray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var base64ImageToRGBArray = function (base64, callback) {
22
var img = new window.Image()
3-
img.onload = () => {
3+
img.onload = function onImageLoad() {
44
var canvas = document.createElement('canvas')
55
var ctx
66
var data

0 commit comments

Comments
 (0)