How to get Photo dimensions after loading photo in capture-photo?

We have a problem that users upload too large photos through the capture-photo component. I didn’t find any built-in method for Attachments that would return the image dimensions (to check the dimensions and immediately give a warning).
The option to use CC tasks is not suitable, since the photo uploading can take place offline and we should immediately show a warning after the photo was uploaded.
Thanks in advance!

1 Like

@khilda You can estimate the size of the attachment as described here. Based on my understanding of your needs, this should be sufficient, as it sounds like it is more a question of file size rather than actual image dimensions (although I realize the latter does influence the former)

As for getting the actual dimensions of the image, you may be able to use an NPM package to get the those, but your mileage may vary since you don’t have access to the file system (which is what most image manipulation “software packages” typically require). For a TS app, this should be pretty straight forward, but for a JS app you will need to use a custom HTML component and implement the NPM (or other JS library) using the HTML Bridge / iFrame.

PS. This looks promising since it seems to support Buffers as an input to synchronous implementation.

I hope this helps.

1 Like