What is the most lightweight method to load different image file formats in nodejs and read pixels? - node.js

Is there a unified and lightweight method for loading multiple common image file formats in NodeJS which provides read access to individual pixels?
It should support gif, jpeg, and png.
Preferably it would either support other image formats too or provide a way to add more. (webp, etc.)
It does not need to be able to save the file again after modifying pixels, provide metadata access, or anything else.
It doesn't need to be able to load images from URLs.
So far the libraries that support multiple image formats are heavyweight, such as providing full canvas support or full image processing support.
Is there a lightweight way to do this that I'm not finding?

I don't know why I couldn't find this one before posting here:
get-pixels
Given a URL/path, grab all the pixels in an image and return the result as an ndarray. Written in 100% JavaScript, works both in browserify and in node.js and has no external native dependencies.
Currently the following file formats are supported:
PNG
JPEG
GIF
It hasn't had any updates for two years but seems the most lightweight. I'm guessing people might mostly use Jimp these days. It doesn't seem to have external dependencies and is actively developed, but includes a lot of image processing functionality I don't need.

Related

Extract vectorized data from a pdf with non-embedded fonts

My question is about how PDF viewers handle fonts used in a PDF that are not embedded.
I'm using software (pdfjs-dist) to generate thumbnails from PDF's and noticed that text is often missing in the resulting image.
Upon further inspection it turns out that fonts are missing on the OS (which is a node docker container (linux)).
Now, I have heard that it's possible to always generate a render from a PDF, using some sort of layer in the PDF that contains vectorized data which you can view,
even when the fonts are not embedded in the PDF nor available in the operating system.
Has anyone heard of this mechanism that can point me to its technical name?

How to convert an Enhanced Windows Metafile (emf) to a JPG or PNG without loosing quality?

I am using Tableau to do some data representations and the only good quality image export Tableau allows is *.emf
Unfortunately, the online tool I use to put the report together(Canva) does not support emf format.
When I convert the file to jpg or png, the quality is drastically reduced :(
How can I overcome this matter? I tried many things such as opening emf in Illustrator and saving back with CMYK colors and 300dpi and such. But nothing seems to keep the crisp quality of the original emf file.
User Friendly solution:
InkScape opens enhanced windows metafiles, and many other vector-graphical file formats.
It exports to png with choice for output's resolution
It is opensource and available for Linux, windows and Mac OS X.
It is a fact that Tableau's image export feature does not provide many options. In general when I need high quality images, I use one of the below methods depending on the quality I need and the tools available to me at that time:
Screenshot method: If you have a large screen, taking a screenshot directly from Tableau yields better images than the exported ones. If my viz is exported to web, I sometimes enlarge the graphic from my web browser and then take the screenshot.
Converting from PDF: Since PDF can contain vector objects, Tableau's PDF files are in high quality most of the times. If you cannot use these PDF files, you may try converting these files to PNG or JPG files using online or desktop tools. Here is an online tool you may use for this purpose, but be careful about your confidential files when using such online services :)
And there are more ways to convert from PDF but are usually more complicated since they contain some Photoshop steps. I am not sure whether these are easy to apply methods for a lot of files but still you may want to check one of them: https://community.tableau.com/thread/120134

JPG image partially gray while loading

Anyone knows why the image, shown below, is partially gray while loading? I assume it has something to do with progressive JPG, but I haven't seen the grayscale effect before. Is there some kind of a JPG export setting that enables that? How is it called? Can I disable it?
Direct image link
Edit:
The problem could either be the problem described in #KonradDzwinel answer OR my answer, both could look identical:
What is the problem
For some reason the file is saved or produced in way that make the file we call it Lossless JPEG.
I am not sure which software, tool or how this problem is was produced, but that won’t change the fact that your file had have some issues or even corrupted.
How to find the problem in the file
Your file was saved in way that it works identical but it had issues. To check whether your file is healthy or not, it requires a tool to scan/analysis the image file. I use a very nice and easy to use tool (software) called JPEGsnoop (link for download). This tool is free and I used it to scan and analysis your image files for problems.
Your file comes up with few places with following note, (the screen-shot btw shows only one note, but there were more):
NOTE: Scan parsing doesn’t support this SOF mode.
After I have re-saved the file correctly and analysis it again, it does not show any problems or notes:
What I did to create a problem FREE image file
For testing I have used Photoshop 5.5 to open the Lossless file and save it with new name with default jpeg (since I don't have the original file). But correctly I assume you have the original file, and I assume you have Photoshop any version does not matter OR any other image tool. Try to optimize your jpeg file best possible, analysis it and remember/note the saving setting for future wise image saving.
Here is an example of my Photoshop save settings, which result in problem FREE file:
How can I learn more about Lossless JPEG
I won’t go in details of this problem but I will leave some link that explain it in details, I hope also you find this is useful to solve your issue:
http://www.impulseadventure.com/photo/fix-corrupt-jpeg-photo.html
http://fileformats.archiveteam.org/wiki/JPEG
http://fileformats.archiveteam.org/wiki/Lossless_JPEG_%28original%29
http://www.howtogeek.com/142174/what-lossless-file-formats-are-why-you-shouldnt-convert-lossy-to-lossless/
Software JPEGsnoop
http://www.impulseadventure.com/photo/jpeg-snoop.html
Progressively encoded JPEGs contain ten scan layers by default. That means ten iterative layers of image information build on each other to deliver the final visual quality of the image. The first visible scan layer of a progressive JPEG is always highly pixelated and often black & white because it saves on color channel information.
Source (emphasis mine)
Another resource that explores this issue in lengh: http://cloudinary.com/blog/progressive_jpegs_and_green_martians

Need to know standards for png file in web graphics?

I'm starting to venture out from using jpeg and gif files to png, I was wondering if there were any standards for using png beside IE's lack of support for it. I also want to know if there was any current articles about setting I should be using when optimizing for web? Right now I'm using photoshop to do this, should I be using firework instead?
Which optimizations you use depends on the type of image. If your image contains only few colors, you might use png-8, otherwise you may need png-24. Same goes for the use of transparency/alpha blending.
The Photoshop save for web-feature does a fine job, but when your website has a lot of visitors, you may benefit from using PNGCrush for further compressing your images. You can use the YSlow plugin for FireFox to test how much bandwidth you can save by crushing your images.
Also, you can make use of CSS-sprites if your design allows it. This can result in less (but larger) images and therefore less requests and sometimes less bandwidth. But this doen't depend on the type of images you use.
Png is supported by IE, by the way. Only the alpha-transparency is not supported by IE 6, but there are CSS/Javascript trics to work around that, although they do not work for background images.
I wouldn't quit using jpg. Jpg is very useful when it comes to pictures. Png files are convenient for small images like buttons, graphical elements, and for images with large plain areas, like screenshots.

Parse a png image into many png images in J2ME

Can anyone tell me how i can parse a png image into many png images in J2ME ? I want to write a code that take a image and give many images that have equal pixels.
You mean you want to cut it into smaller images?
Load the image.
Convert to a bitmap.
Encode arbitrary rectangles as PNG.
Save the PNGs.
Unfortunately, I don't know anything about image processing usinf J2ME libraries.
Here's what I googled as far as loading a PNG in J2ME.
Using that, you'll be able to see the API calls used, and following the import list, you'll get to the classes used. Look at those class's methods, and yu'll probably come up with what you need.
I did this mostly because you're having an emergency, but frankly, you could have googled this yourself, or composed a question that was clearer, which would have led to someone more knowledgeable about J2ME image processing helping you.
Just don't panic, take a breath, google for what you need, you'll be fine.

Resources