Converting heic/heif to jpg in react native (or nodejs) - node.js

I have a react native app on ios where users can upload photos. I resize these photos server-side with sharp. The problem is:
the HEIC/HEIF-files from ios are not compatible with sharp. I get the following error:
¡Error: source: bad seek to 2808991
heif: Unsupported feature: Unsupported codec (4.3000)
¿
Is there a way to get a JPG version of the photo? It's also ok if I have to convert the file to jpg on the server, but how can I detect the codec of the image (so that only HEIC/HEIF images are converted, and not jpg or png)?
How can I convert them client side or server side?

React Native Image Resizer can perform HEIC to jpeg compression on the app. It's a native module so you'll have to build a development client if you're using expo.

Related

Unable to use puppeteer in a nodejs app on cpanel?

I am using puppeteer in my nodejs application to convert html file into pdf. This is working fine in my local server and pdf is getting generated. But this is not working in cPanel. I am getting error similar to this. I tried everything mentioned on that but nothing works.
I tried setting the executable path of chrome in puppeteer in cpanel but in vain. Errpr =>
Failed to launch the browser process!
/home/xxx/public_html/xxx/node_modules/puppeteer/.local-chromium/linux-1002410/chrome-linux/chrome: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directory
I tried different packages like html-pdf and node-pdf-generator. But the problem is I have designed some ejs templates according to chrome and then I am generating html files from these ejs templates. After that I am saving the pdf file in buffer and uploading this buffer to google bucket.
Flow: ejs templates -> html file -> pdf buffer -> stream buffer to gc
bucket
In other packages I am facing these issues:
Either the template is not coming as expected
Or The package has no option of storing generated pdf file in buffer.
Any solution or a different library?

node.js fs Readstream event handler never called in Node 12.3.1

In custom build CEF-74 with nodeJS 12.3.1 -> we're loading a webApp from which we're downloading images from google drive and google photos, first time downloading of image works fine, but for already downloaded images, node.js fs.CreateReadStream() event handler checks MD5 hash of local file, determines that the asset has already been downloaded.
which is not working here in this case unless we enable --mixed-context on.
what role does --mixed-context might be playing here to make this workflow of md5 hash work?

How can I create a MediaStream track from a continuous stream of images in node.js? (for usage with WebRTC)

I want to stream a robot cam from a web media element. I have access to the camera in node.js, which is providing a live stream of images (continually producing a new frame at ~20fps).
In this same situation in the browser, one could write the image to a canvas and capture the stream.
Is there some way to construct a MediaStreamTrack object that can be directly added to the RTCPeerConnection, without having to use browser-only captureStream or getUserMedia APIs?
I've tried the npm module canvas, which is supposed to port canvas to node -- then maybe I could captureStream the canvas after writing the image to it. But that didn't work.
I'm using the wrtc node WebRTC module with the simple-peer wrapper.
Check out the video-compositing example here.
https://github.com/node-webrtc/node-webrtc-examples

Uploading large tiff files in nodejs

I am developing a web app using MEAN Stack and Angular 6. I want to upload tiff files(maps) with large file size.(max size is around 1.4 GB).I used 'ng2fileUpload' and 'multer' for that but it does not allow to store large files. Is there any good method to use for uploading large files in nodejs. My preavious post is on this link. 'Uploading files using multer gives 'request entity too large' error'
You should check first if there is a limit on max upload on the server site instead of the client side. There is a limit with apache service.

how to save the binary of image of multi part form in node js

upload imageI am trying to make upload image in pure nodejs, please don't ask me why you do that cuz I am obliged to make it in pure node js I parsed the request header and I checked about image uploading or any files and I have in the console these bytes of image req data. and I**strong text** am tried to save it with fs module and the image saved successfully but when opening it gives me "this file format can't be opened"
how can i save the uploaded image ??

Resources