Skip to content
Advertisement

Angular – Generate thumbnails for uploaded image/video

I have an Angular application where a user can upload files. I want to generate a thumbnail image for files that are images/videos. Basically, all I have is the file bytes and type, I do not save the file in the app, I just forward it to another API. I don’t want to save the generated thumbnail locally, I just want to forward it along with the original image/video.

I’ve found the package simple-thumbnail but I see that it requires either the file path (which I don’t have since I do not save the file in my app) or the image URL (which also I don’t have since the user upload the image from his computer). Also, this library saves the file, which I don’t want.

Is there any way to generate an image thumbnail out of image/video bytes, only to forward it further along with the original file?

Advertisement

Answer

You can try to create a video element and set your video to it. After loading the video inside the element a canvas can be used to extract an image from that video. This might be useful https://stackoverflow.com/a/63474748/10143503

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement