Skip to main content

Hi !


I would like to be able to detect wether a fill of type image contains transparency or not.


I’m developping a code exporter and there are multiple reason why this information would be useful, for example :




  • knowing wether its more relevant to export as PNG or JPG (without having to ask the user)




  • knowing wether a shadow effect applied to that image should rather be handled in CSS (in the case of a jpg without transparency) or should be integrated in the export (in the case of a png with transparency)




please let me know if there’s any way to know this, (even a work-around)


Best regards.

Get the image fill byte array and analyze the data signature to match the file formats.

figma.com

Thanks for all the resources, this sounds like a reliable solution,

And is there any other way to do it before the async call to Image.getBytesAsync ?


Cheers


No, there are no other ways to get the image format without getting its bytes.


Reply