What is the best way/choice to handle a lot of images


#1

I am new in electron, and i am trying to make an app to handle images from my local drive and display them on the app.(like a photogallery) First of all i tried to handle images as they are, and i found that it took a lot of time and resources to render them on my app, because i need to display a lot of images at one window.
It took all the machine memory and processor time to handle them.
It seems that i need to use some tool/way to make thumbnails and to display them first during loading all the images, googling for some time i found some ways of using imagemagick/graphicsmagick tools…
But all this ways need imagemagick/graphicsmagick to be installed on your machine…

Are there any ways, how i can in easy way create a list of image thumbnails that are in local drive, save them and display on main page of my app?
Or maybe there are some differen ways to solve my problem?
I need thumbnails like 200x200 px.


#2

It doesn’t necessarily have to be installed on the machine if you include it with your app and call the specific version located in your app’s directory.


#3

Damned, thank you for your reply, but anyway i tried to handle images this way and even to handle 50 images took a lot of memory and processor time, and i need to handle even more than 200 - 300 images.
Also i tried to use “nativeImage” class from electron library to create thumbnails of images. This is my code:
fs.readdir(folder, function(err, files) {
if (err) {throw err;}
files.forEach(function (file) {
var fullFilePath = path.resolve(folder,file);
var resFilePath = path.resolve(resizedFilePath,file);
let image = nativeImage.createFromPath(fullFilePath);
console.log(image);
});
});

And it doesn’t work in log i can see that nativeImage create an empty files(even if there are no images or incorrect path), but fullFilePath - is the right location of files. Maybe you can advise me what the problem in my code?


#4

Not without more information. I don’t know what “a lot of memory and processor time” means in your context, I don’t know what you’re trying to manipulate, and you’ve posted just the tiniest segment of code. When you share code with other people, make sure to format it properly. It’s much harder to read if it’s not monospaced.

The easiest way to get people to take the time to help you is to make your code available in a GitHub repo where it can easily be cloned and plugged in.