You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw this example here on the site last year. I thought I'd try it again with the latest version of Jimp, because the old one unfortunately turned 16-bit image datas into 8-bit datas. I downloaded topology files from NASA. These have the hgt format and for this I wrote a small decoder in python and it then turns them into 16-bit grayscale images. In gimp I then see that the image file also has 16 bits and if I use fast-png then it also reads the 16 bit pixel data correctly. But I'm looking for a decoder that can also do this with jpg images, because png images are significantly larger and take longer to load because the alpha channel is also included, which I don't need at all. Where can I find the JIMP script to be integrated in webworker? I've searched the folder and can't find anything. Maybe I'm just being clumsy.
In my software I integrate everything via import because I bundle it with webpack. Then I want to use electron. That's why it's so important for me to have a 16-bit image decoder that doesn't have any node dependencies. With fast-png I have resolved all node dependencies so that it runs purely frontend. That was quite a hassle and I`m happy that it works, but it's still the png format and i urgently need the jpg format for better performance.
Where can I currently find the JIMP code to be integrated into the webworker?
Is there perhaps a new example if something has changed fundamentally?
The html-File:
<!DOCTYPE html>
<html>
<head>
<title>Jimp browser example 3</title>
</head>
<body>
<h1> Demonstrates loading a local file using Jimp on a WebWorker thread </h1>
<p><input type="file" onchange="newFiles(this);" /></p>
<script>
function newFiles(element){
for (var i=0; i<element.files.length; i++) {
readFileAndProcess(element.files[i]);
}
function readFileAndProcess(readfile){
var reader = new FileReader();
reader.addEventListener("load", function(){
var worker = new Worker("jimp-worker.js");
worker.onmessage = function (e) {
var img = document.createElement("img");
img.setAttribute("src", e.data);
document.body.appendChild(img);
};
worker.postMessage(this.result);
});
reader.readAsArrayBuffer(readfile);
}
}
</script>
</body>
</html>
The worker-script:
importScripts('./jimp.min.js'); //where can i find this file or an equivalent jimp file that I can include with import?
self.addEventListener('message', e => {
Jimp.read(e.data).then(lenna => {
lenna
.resize(256, Jimp.AUTO) // resize
.quality(60) // set JPEG quality
.greyscale() // set greyscale
.getBase64(Jimp.AUTO, (err, src) => {
if (err) throw err;
self.postMessage(src);
self.close();
});
});
});
I'm sorry that I can't actively support the further development, because my project is already taking up all of my free time.
Here is an example with fast-png in three.js but i would like to do it with jimp and 16 bit jpg files.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I saw this example here on the site last year. I thought I'd try it again with the latest version of Jimp, because the old one unfortunately turned 16-bit image datas into 8-bit datas. I downloaded topology files from NASA. These have the hgt format and for this I wrote a small decoder in python and it then turns them into 16-bit grayscale images. In gimp I then see that the image file also has 16 bits and if I use fast-png then it also reads the 16 bit pixel data correctly. But I'm looking for a decoder that can also do this with jpg images, because png images are significantly larger and take longer to load because the alpha channel is also included, which I don't need at all. Where can I find the JIMP script to be integrated in webworker? I've searched the folder and can't find anything. Maybe I'm just being clumsy.
In my software I integrate everything via import because I bundle it with webpack. Then I want to use electron. That's why it's so important for me to have a 16-bit image decoder that doesn't have any node dependencies. With fast-png I have resolved all node dependencies so that it runs purely frontend. That was quite a hassle and I`m happy that it works, but it's still the png format and i urgently need the jpg format for better performance.
Where can I currently find the JIMP code to be integrated into the webworker?
Is there perhaps a new example if something has changed fundamentally?
The html-File:
The worker-script:
I'm sorry that I can't actively support the further development, because my project is already taking up all of my free time.
Here is an example with fast-png in three.js but i would like to do it with jimp and 16 bit jpg files.
Beta Was this translation helpful? Give feedback.
All reactions