Comments (9)
The issue with odd-sized images appears to be resolved with new libultrahdr-esm, I think the PR can be merged and this issue can be closed.
However, I've encountered a new issue related to decoding certain gainmap JPEGs. I plan to conduct further investigations on my own and will open a new issue once I have a better understanding of the problem.
Thanks
from gainmap-js.
Yes the problem seems the libultrahdr WASM module which, apparently, cannot allocate its memory for some reason.
Can you give more detailed reproducibility steps?
Where are you executing this functions? are you building an app with the library and executing these functions in your code? are you using our tool at https://gainmap-creator.monogrid.com/ ?
Can you attach an example of an .hdr
file which fails encodeJPEGMetadata
and the code you execute?
from gainmap-js.
this is the small one
small.hdr.zip
and the big one
https://drive.google.com/file/d/1xRIhNjbb6CLqXiFaAemn7cfcgJ5FYaml/view?usp=sharing
2 samples
from gainmap-js.
ok, the big one fails in https://gainmap-creator.monogrid.com (which uses the library).
I'm not sure why this happens because we've tested the library (among others) with 8k versions of this image https://polyhaven.com/a/qwantani_puresky which is 289MB, bigger than yours both in file size and resolution
or this one https://polyhaven.com/a/metro_noord , 8k, exr, 387MB, compressed with 0.99 quality, and an output of nearly 20.3MB jpeg
all with no problems π€
I'm going to need to investigate this
from gainmap-js.
and for jpg gainmap repack failed, my code:
import { GainMapLoader, HDRJPGLoader, extractGainmapFromJPEG } from '@monogrid/gainmap-js'
import { compress, encode, findTextureMinMax } from '@monogrid/gainmap-js/encode'
import { encodeJPEGMetadata } from '@monogrid/gainmap-js/libultrahdr'
async function loadImageAndGetDimensions(url) {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => {
resolve({ width: img.width, height: img.height });
};
img.onerror = reject;
img.src = url;
});
}
async function fetchAndDetermineImageDimensions(url) {
const response = await fetch(url);
const arrayBuffer = await response.arrayBuffer();
const originalJpeg = new Uint8Array(arrayBuffer);
const blob = new Blob([originalJpeg], { type: 'image/jpeg' });
const newUrl = URL.createObjectURL(blob);
const dimensions = await loadImageAndGetDimensions(newUrl);
return dimensions;
}
process();
async function process() {
const inputUrl = 'textures/gainmap/03.jpg';
const { width, height } = await fetchAndDetermineImageDimensions(inputUrl);
const originalJpeg = new Uint8Array(await (await fetch(inputUrl)).arrayBuffer());
const decodingResult = await extractGainmapFromJPEG(originalJpeg);
const mimeType = 'image/jpeg';
const sdr = {
data: decodingResult.sdr,
mimeType,
width,
height
};
const gainMap = {
data: decodingResult.gainMap,
mimeType,
width,
height
};
const jpeg = await encodeJPEGMetadata({
...decodingResult.metadata,
sdr,
gainMap
});
}
failed jpg:
03.zip
in fact 01.jpg and 02.jpg from adobe sample worked, but 03.jpg failed
from gainmap-js.
https://gainmap-creator.monogrid.com/
I think I uploaded wrong small one, this new one does not work in your creator
from gainmap-js.
Alright, I found the problem in the code I used to instance the image in memory (which was copy/pasted from the official libultrahdr repository). It apparently didn't allow for odd sized images (width or height not divisible by two π )
I don't know why this restriction was there but I can't see any (apparent) reason it was needed.
I've opened pull request #31 on branch feature/odd-image-size-fix
Are you able to test your files using that branch and report? (you may need to run you may need to git submodule update
cd libultrahdr-wasm
and git checkout b077d0
after checking out the branch, make sure your libultrahdr-was folder contains the "fuzzer" folder, not present before)
The two files you sent now work for me but it would be better to have a complete report before merging, thanks!
from gainmap-js.
I can not build libultrahdr-wasm on my mac (any version)
previously I used the wasm/js file from your published npm package
from gainmap-js.
libultrahdr-esm.zip
try this one, also that error is present in newer emscripten versions but not the one used by the library, I've yet to understand why it happens (something to do with typescript definition generation?) but, for now, the latest supported emscripten version is 3.1.47 (I'll write it in the README)
from gainmap-js.
Related Issues (19)
- sdrJPEG from Loader for custom shader skybox HOT 2
- Artifact in converted .hdr HOT 8
- Decoder hang with invalid URL HOT 4
- peerDependencies < 0.159.0 HOT 3
- ios 14 webgl1 HOT 5
- Can't build the project HOT 1
- Confusion about gainmap-js HOT 6
- .setRenderer(gl) on the LoaderBase class HOT 1
- No βexportsβ main defined in @monogrid/gainmap-js HOT 9
- Docs for encoding seem out of date? HOT 2
- Put decoder library on npm or CDN link for easy import
- Is it possible to use hdrjpg's with Scene.BackgroundRotation and Scene.BackgroundBluriness in threejs? HOT 3
- HDRJPGs with resolutions higher than 4K crash on mobile (iOS iPhone 15) HOT 3
- Kudos to you - Readme suggestion HOT 3
- Uploading file with .hdr.jpg extension online encoder fails HOT 2
- using encode wasm libultrahdr with node HOT 2
- [Bug] Not working with WebGPURenderer HOT 2
- Support for WebGPU Renderer HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gainmap-js.