How to validate image dimensions of an uploaded image

Hey @Varun_Damani! Thanks for reaching out. This isn't something that Retool natively supports, but there's definitely a workaround. :+1:

Attaching an image to the fileButton component exposes the following data, none of which immediately tells us its dimensions:

image

However, it's possible to construct a data URL for this image and read its dimensions that way.

In this particular example, I've also defined a variable called imageValidation that I reference from within a custom validation rule.

image

I hope that helps! Let me know if you have any additional questions.

2 Likes