Is it possible to get an asset's raw data?

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
velocity1029
Kobold
Posts: 4
Joined: Sun Sep 19, 2021 4:02 pm

Is it possible to get an asset's raw data?

Post by velocity1029 »

I need to get the raw data of a token's image so I can convert it to base64 and send that to an API using a REST post.

So, I either need a way to get the raw data of an image from its assetid within a macro, or have some way to get data from local files and access the assetcache folder of maptools to get the raw data into a macro. I'm not sure if the former is possible and as far as I've seen there's not really any way to get data from local files into a macro.

Any ideas would be greatly appreciated!!

User avatar
aliasmask
Deity
Posts: 8733
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Is it possible to get an asset's raw data?

Post by aliasmask »

Not within MapTool. You can use an online tool to get the base64 value of an image. There may be some js libraries online that will allow you to upload a file locally and then give you the base64 values. That still wouldn't have a direct connection to tokens. Maybe do a feature request to update the getAssetProperties function to include base64 data.

velocity1029
Kobold
Posts: 4
Joined: Sun Sep 19, 2021 4:02 pm

Re: Is it possible to get an asset's raw data?

Post by velocity1029 »

Sounds good, thanks for the response.

Post Reply

Return to “Macros”