How to get the original image file type (png, jpg, etc.) of an image?

827 Views Asked by At

I am trying to export images used in layers.

The image fills API (GET/v1/files/:key/images) returns a map of [ imageRef , URL ] but there's no way to know the image file type. For example, the URL doesn't have the file type.

This is kind of a show stopper :(

Ideally, I'd like to know the original file name and type(the actual image which the designer browsed), but just the file type is OK

1

There are 1 best solutions below

0
On BEST ANSWER

You first have to fetch a list of all the images of the document with GET /v1/files/PROJECT_HASH.

Then, depending on the element name/id you have, you will cross check it against your list and get the corresponding file url.

The file url is from amazon aws and it contains a file extension like .jpg, .png, etc.That's your actual image name, not that random hash that figma shows in the main json block.