Skip to content

Support for more image formats (including TIF and PSD)#365

Merged
RvanderLaan merged 35 commits into
masterfrom
more-image-formats-without-native-deps
Nov 21, 2021
Merged

Support for more image formats (including TIF and PSD)#365
RvanderLaan merged 35 commits into
masterfrom
more-image-formats-without-native-deps

Conversation

@RvanderLaan

Copy link
Copy Markdown
Collaborator

Added support for more image formats

  • Full support for: TIF, SVG and APNG
  • Thumbnail-only support for: PSD and KRA

Also added a new settings panel for selectively disabling formats by file extension

This has been a long time coming. At first I tried to get OpenImageIO to work, which would be able to read pretty much any file format. This ended up taking very long, so I gave in and went with Sharp for just getting TIF support, which worked nicely, but not in the packaged Electron version. In the end I just went with a javascript-only library: UTIFF (used by Photopea).

For PSDs, the thumbnail is extracted using exiftool, which only produces a low res thumbnail, but it's better than nothing. If you don't want it, you can just disable it in the settings. For KRA, the file can be parsed as a zip file which contains a thumbnail. It contains a full-size image we could use as well if we want

allusion-more-media-formats.mp4

It works in dev mode, but the packaged version cannot load the native sharp module yet
- Completed support for .tiff files and a bunch of other formats like exr (#279)
- Added partial support for .psd and .kra files (#361). Only the thumbnail is loaded
- Cache extracted full images (e.g. for tiff) so it doesn't need to be converted repeatedly
- Added WIP panel to settings for disabling file formats
@hummingly hummingly mentioned this pull request Oct 9, 2021
@RvanderLaan

Copy link
Copy Markdown
Collaborator Author

👍 🏅 Lookin good! Ready to merge imo

@hummingly

hummingly commented Oct 16, 2021

Copy link
Copy Markdown
Collaborator

Actually, I accidentially pushed my changes 😂 The only thing left I wanted to try out was using the usePromise hook in the gallery item because it tends to just show an error when loading for the first to three times.

Btw I think I've got basic rgba exr loading on my machine in only 400KB WASM lol However, I had to turn off multi threading, so it's crawling in comparison to native. I think tif and exr loader should be put in its own thread because it otherwise it blocks the Promises.

@hummingly

Copy link
Copy Markdown
Collaborator

This adds experimental support for exr files using the exr-rs crate. The crate is surprisingly featureful with the exception of deep data and dwab decrompression. So, far the code only handles rgba files and converts it to srgb (I think Electron cannot display hdr images anyways). Adding support for Lab or YCbCr should be possible. Worst case I convert everything to rgba :)

Before the next release we need to put the loaders in a worker because it is really slow right now. I could make the color conversion faster with SIMD but before that we need to figure out how to upgrade Electron.

@RvanderLaan

Copy link
Copy Markdown
Collaborator Author

awesome, it works great for a few sample EXR images I found. Didn't notice any real performance issues

@hummingly

Copy link
Copy Markdown
Collaborator

TODO: Prevent creating multiple tasks for same images while generating.

@RvanderLaan

Copy link
Copy Markdown
Collaborator Author

TODO: Prevent creating multiple tasks for same images while generating.

I'm just merging it now since it has some nice goodies. Users can disable EXR support if they experience problems so it should be fine

@RvanderLaan RvanderLaan merged commit 0d20ada into master Nov 21, 2021
@hummingly hummingly deleted the more-image-formats-without-native-deps branch January 8, 2022 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants