Extract snapshots from video at a given time using video-thumb module - node.js

I want to create thumbnail from a video at a certain time in node js, now I am using node module "video-thumb"
This is the code that uses node-thumb module to create thumbnail
And this is the result however the result is shown but don't know where the snapshot.png

Related

AWS Rekognition: Requested image should either contain bytes or s3 object

I am doing a mock content moderation labeling using AWS Rekognition on React, but no matter what available image format (bytes, S3 object) I submitted, Rekognition never recognizes it, giving Unhandled Rejection (InvalidParameterException): Requested image should either contain bytes or s3 object.
I have followed Rekognition's guideline here, StackOverflow solutions: 1. Converting into Bytes as an Image param here, 2. Using S3 Object here, 3. Using Buffer to read image here, 4. Using raw file input to upload image (this one definitely did not work), 5. Checking if my image is corrupted or not here – in fact I tried with more than 20 images and all failed, 6. Stripping EXIF data here.
Library I use: node-rekognition (I use an old package because my huge node app is still runs on version 12.13.0), React 16 (class component approach)
Feel free to request any additional info if I lack some. Thanks.

Image resolution low after converting pdf to image using GraphicsMagick for NodeJS

I'm trying to convert pdf into image using gm package and i just can't understand how should i adjust the output resolution.
If i'm doing like this:
gm(`${sourcePath}[0]`)
.setFormat('jpg')
.stream()
.pipe(writeStream);
The output quality here is very low, so i'm trying to use density(594, 842)
like this:
gm(`${sourcePath}[0]`)
.setFormat('jpg')
.quality(100)
.density(595, 842)
.stream()
.pipe(writeStream);
but doing this the image looks very starchy.
Can anyone please point me what should i do in order to receive the
output image close as possible to the pdf source using the npm package?
Or maybe recommend me about a different library that i can use for converting pdf to image (before ocr)

express-fileupload:get check size in express js

I am using this package
to upload the image into server ,i want to check the file size before upload but express-fileupload doesn't give any information about it
console.log(req.files.image); it returns only the name,data ,and image type
Assuming the name of your file in your HTML file is image, req.files.image.data.length will give you the buffer length in bytes. See this Node.js. API Documentation for more details. You can then do the math to convert the number of bytes into any thing you want.
This will allow you to get the actual number of bytes independent of filetype and doesn't require using the mv function. So you can use this on any file type not just images.
Hopefully this helps!
I think only way to get image info using express-fileupload is using mv function to move image on server then using image-size to get width and height

How to resize images on node.js

So basically my front end is displaying images that are about 3-5mb. I need to find a way to make their size way smaller.
Basically I have the file object on node.js uploading to amazon aws. I just need to compress it before it uploads.
Also whats the best way to resize images on node.js?
The best way is use Canvas Node js module. This module is up to 3 times faster than ImageMagic.
Images manipulation comparation - https://github.com/ivanoff/images-manipulation-performance
author's results:
canvas.js : 4.001 img/sec;
gm-imagemagic.js : 1.206 img/sec;
gm.js : 1.536 img/sec;
lwip.js : 0.406 img/sec;

NODEJS Canvas to base64 png stream

Imagine that i have a client that only can read base64 images and i want to show that images like a realtime movie (as less latency as possible).
This images are created on server side using nodejs canvas lib. For each image that i send to the client i see the difference between them with imagediff nodejs lib and i only send the difference match image.
In the client side i show it putting the last image exactly over the previous ones (layers).
The problem is that in server side i have the following values that slow down the process:
16ms: after draw canvas:
42ms: imagediff (imagediff nodejs lib)
[100 to 250ms] - toDataUrl (canvas to png base64 - canvas nodejs lib toBuffer().toString('base64'))
The big issue is in 3.
Do you have a different solution for this?
Thanks for your time.
Eduardo

Resources