diff --git a/src/codecs/browser-jpeg/decoder.ts b/src/codecs/browser-jpeg/decoder.ts index 9eb56c1a..d6107bdd 100644 --- a/src/codecs/browser-jpeg/decoder.ts +++ b/src/codecs/browser-jpeg/decoder.ts @@ -1,4 +1,4 @@ -import { canDecode, fileToBitmap } from '../../lib/util'; +import { canDecodeImage, fileToBitmap } from '../../lib/util'; export const name = 'Browser JPEG Decoder'; export const supportedExtensions = ['jpg', 'jpeg']; @@ -11,5 +11,5 @@ export async function decode(file: File): Promise { const jpegFile = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAn/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AJVAA//Z'; export function isSupported(): Promise { - return canDecode(jpegFile); + return canDecodeImage(jpegFile); } diff --git a/src/codecs/browser-png/decoder.ts b/src/codecs/browser-png/decoder.ts index e3ecea45..357b0ab9 100644 --- a/src/codecs/browser-png/decoder.ts +++ b/src/codecs/browser-png/decoder.ts @@ -1,4 +1,4 @@ -import { canDecode, fileToBitmap } from '../../lib/util'; +import { canDecodeImage, fileToBitmap } from '../../lib/util'; export const name = 'Browser PNG Decoder'; export const supportedExtensions = ['png']; @@ -11,5 +11,5 @@ export async function decode(file: File): Promise { const pngFile = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII='; export function isSupported(): Promise { - return canDecode(pngFile); + return canDecodeImage(pngFile); } diff --git a/src/codecs/browser-webp/decoder.ts b/src/codecs/browser-webp/decoder.ts index 450f0d37..baa962fd 100644 --- a/src/codecs/browser-webp/decoder.ts +++ b/src/codecs/browser-webp/decoder.ts @@ -1,4 +1,4 @@ -import { canDecode, fileToBitmap } from '../../lib/util'; +import { canDecodeImage, fileToBitmap } from '../../lib/util'; export const name = 'Browser WebP Decoder'; export const supportedExtensions = ['webp']; @@ -11,5 +11,5 @@ export async function decode(file: File): Promise { const webpFile = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA='; export function isSupported(): Promise { - return canDecode(webpFile); + return canDecodeImage(webpFile); } diff --git a/src/codecs/webp/Decoder.worker.ts b/src/codecs/webp/Decoder.worker.ts index 9975a4e7..d09fae11 100644 --- a/src/codecs/webp/Decoder.worker.ts +++ b/src/codecs/webp/Decoder.worker.ts @@ -32,7 +32,7 @@ export default class WebpDecoder { }, onRuntimeInitialized() { // An Emscripten is a then-able that, for some reason, `then()`s itself, - // causing an infite loop when you wrap it in a real promise. Deleten the `then` + // causing an infite loop when you wrap it in a real promise. Deleting the `then` // prop solves this for now. // See: https://github.com/kripken/emscripten/blob/incoming/src/postamble.js#L129 // TODO(surma@): File a bug with Emscripten on this. diff --git a/src/codecs/webp/decoder.ts b/src/codecs/webp/decoder.ts index d5f89a08..685a2d7e 100644 --- a/src/codecs/webp/decoder.ts +++ b/src/codecs/webp/decoder.ts @@ -11,6 +11,5 @@ export async function decode(file: File): Promise { } export async function isSupported(): Promise { - // TODO(@surma): Should we do wasm detection here or something? return true; } diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx index ed10c255..9cfc88a2 100644 --- a/src/components/App/index.tsx +++ b/src/components/App/index.tsx @@ -184,7 +184,6 @@ export default class App extends Component { if (!decoder) { throw new Error('Can’t find a decoder for the given file'); } - console.log(`Decoding using ${decoder.name}`); const bmp = await decoder.decode(file); // compute the corresponding ImageData once since it only changes when the file changes: const data = await bitmapToImageData(bmp); @@ -251,7 +250,7 @@ export default class App extends Component { loadedCounter: loadingCounter, }; - this.setState({ images }); + this.setState({ images, error: '' }); } render({ }: Props, { loading, error, images }: State) { diff --git a/src/lib/util.ts b/src/lib/util.ts index d4f7cc2b..1c731b09 100644 --- a/src/lib/util.ts +++ b/src/lib/util.ts @@ -96,7 +96,7 @@ export async function canvasEncode(data: ImageData, type: string, quality?: numb return blob; } -export function canDecode(data: string): Promise { +export function canDecodeImage(data: string): Promise { return new Promise((resolve) => { const img = document.createElement('img'); img.src = data;