pngjs | Pure JavaScript PNG decoder | Runtime Evironment library
kandi X-RAY | pngjs Summary
kandi X-RAY | pngjs Summary
PNG.js is a PNG decoder fully written in JavaScript. It works in Node.js as well as in (modern) browsers.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Buffer - > String
- Read a 4 - bit 32 - bit buffer from a buffer .
- Recursive comparison of two bytes .
- Read 2 bytes in a buffer .
- read byte in Buffer
pngjs Key Features
pngjs Examples and Code Snippets
Community Discussions
Trending Discussions on pngjs
QUESTION
ANSWER
Answered 2021-Dec-27 at 08:16Those pixels in a PNG (you will need to dramatically embiggen in order to see the six pixels):
Hex dump:
QUESTION
I am trying to create a 16bit heightmap png from a 32bit Rgb encoded height value png.
According to mapbox I can decode their png pixel values to height values in meters with this formula. height = -10000 + ((R * 256 * 256 + G * 256 + B) * 0.1)
I am new to understanding this type of information and have tried to figure it out myself but I need some help.
I found this program called image-js, docs for this program are here . Note I am using this in the browser not with node.
I think it has the abilities that I need. However, I am really not sure how to get the data from the original image and create a new 16bit png with the new height values calculated from the above formula.
If you look in the docs under image I can set many properties such as
bitDepth and set that to 16
getPixelsArray() this function will give me an array of pixels values in the form of r,g,b. I think I can then run each pixel through the above formula to get the height. After that how do I turn this height data back into a 16bit grayscale heightmap png?
Thanks!
Example images. 32bit Rgb encoded height value png
16 bit heightmap png. You have to zoom in to see the image changes
Update:
Thanks to traktor for the suggestion. I wanted to add some information to my question.
I don't necessarily need to use image-js. My main goal is to get a 16 bit heightmap from a 32 bit RGB. So any other browser side javscript method would be fine. I also am using browser side createWritable(); stream to write file to disk.
I have a method used from this nice module https://github.com/colkassad/terrain-rgb-height however I cannot get the browser side version of pngjs to work correctly. I think there is a difference between browser side stream reader/writers and node reader/writers that make it not work.
Thanks!
...ANSWER
Answered 2021-Sep-30 at 18:59Looking through the source code for Image-js
package on GitHub turns up that the options
object used in calls to the library is verified in source file kind.js
which enumerates supported options properties in the assignment statement:
QUESTION
I have written below code which is fetching 3 documents , from that document i want to display only specific filed excluding the other field
...ANSWER
Answered 2021-Aug-15 at 12:59For official node.js MongoDB driver. The syntax for projection is like this
QUESTION
I need to edit 34 000 photos on a pixel scale, so I wrote a program that replaces pixels in an image if they are over a specific RBG value (240, 240, 240), basically I want to isolate only white pixels and set everything else to black. This is my code:
...ANSWER
Answered 2021-Aug-07 at 15:21Alright, so asynchronous done correctly was the answer in the end, credit to NeonSurvivor#2046
for this answer given to me on Discord!
QUESTION
I am writing a project which requires me to load a lot of low resolution PNGs (~10k) to train my neural network. This is my code
NOTE: This project uses 'pngjs' module
...ANSWER
Answered 2020-Aug-16 at 13:40I suppose you would like to await its loading phase before proceeding. Luckily there is a keyword for that; namely await
. It must be paired with async
. Check it out.
Edit: The idea in general is that you would make an array of so-called Promises (related to async and await); one Promise for each image. You can then await the completion of all these asynchronous Promises, i.e. when all images are loaded. And after that you can do what you want while still having all images load asynchronously in beforehand. (Hint: Promise.all)
QUESTION
I'm new to node.js and this is just a small thing I need as part of a project that I'm writing in a different language.
How would I go about using pureimage to make a line from a start position to an end position and exporting it as a png? I'm interested in using pureimage because to my understanding you can set the line width with a variable
I currently have a working program with pngjs-draw but it's impossible to change line width there.
...ANSWER
Answered 2020-Aug-01 at 13:32You can specify the line thickness with the lineWidth property. Then you can draw your line in the canvas 2D context and export your image as a png file with pureimage, like this:
QUESTION
I am ordering images by a score value calculated by the getImageScore
method, which is wrapped in a promise, as it takes quite some time to load the pixels it has to work with. I observed that the promises get blocked, never being finished. This was the initial whole program:
ANSWER
Answered 2020-Jul-13 at 11:16Fortunately, someone from Facebook (Iulian Popescu) told me that files.forEach
doesn't wait for the promises to finish, therefore they get blocked. I managed to solve this situation, by adding more promises. For sample, one of the promises reads all the data. After reading all the data and saving it in some global variables, the other promises would get executed, in the right order. If you'd like to actually see the implementation of the solution I'm talking about, you can check it out on my GitHub: https://github.com/tomaAlex/darkImageClassifier/blob/master/index.js
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install pngjs
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page