# Can albedoTexture be automatically exported in base64 format?

**URL:** <https://forum.babylonjs.com/t/can-albedotexture-be-automatically-exported-in-base64-format/23960>\
**Category:** Questions\
**Created:** [September 20, 2021, 12:05am UTC](https://forum.babylonjs.com/t/can-albedotexture-be-automatically-exported-in-base64-format/23960 "2021-09-20T00:05:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dr.Hell](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@Dr.Hell](https://forum.babylonjs.com/u/Dr.Hell)\
**Post date:** [September 20, 2021, 12:05am UTC](https://forum.babylonjs.com/t/can-albedotexture-be-automatically-exported-in-base64-format/23960/1 "2021-09-20T00:05:19Z")

</div>

Good evening, new question:  
I create some models using MakeHuman, import them in Blender and then export them in Babylon format.  
I’d like to know if there is a way to convert automatically the texture in its base64 format when the model is exported to Babylon.  
I’m asking because I found this issue [base64String data · Issue #21 · BabylonJS/Editor · GitHub](https://github.com/BabylonJS/Editor/issues/21) which had a behaviour very close to what I’d like to attain, so I wondered if there was a legit way to attain the result (if not, I’d need to convert the textures manually, no big deal, just a bit annoying).

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [September 20, 2021, 8:02am UTC](https://forum.babylonjs.com/t/can-albedotexture-be-automatically-exported-in-base64-format/23960/2 "2021-09-20T08:02:42Z")

</div>

It will probably all depends of the tool you are using. In which tool are you planning to do that ?

---

<div class="post-metadata">

**Author:** ![Dr.Hell](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@Dr.Hell](https://forum.babylonjs.com/u/Dr.Hell)\
**Post date:** [September 20, 2021, 8:42am UTC](https://forum.babylonjs.com/t/can-albedotexture-be-automatically-exported-in-base64-format/23960/3 "2021-09-20T08:42:41Z")

</div>

Right now, mostly in Blender.  
I tried to search for any option in the exporter, but of course I didn’t manage to find any.  
Anyway it was almost a curiosity, since I happened to see that issue in the editor that did almost what I needed, but if it requires some passages between Blender and the Babylon Editor, probably it will be easier to just convert them manually. 🙂

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [September 20, 2021, 9:53am UTC](https://forum.babylonjs.com/t/can-albedotexture-be-automatically-exported-in-base64-format/23960/4 "2021-09-20T09:53:22Z")

</div>

Oh maybe @JCPalmer would have a trick for it but I guess, if not, as you mentioned converting manually or through a tiny script might be simpler.

---

<div class="post-metadata">

**Author:** ![Dr.Hell](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@Dr.Hell](https://forum.babylonjs.com/u/Dr.Hell)\
**Post date:** [September 20, 2021, 10:14am UTC](https://forum.babylonjs.com/t/can-albedotexture-be-automatically-exported-in-base64-format/23960/5 "2021-09-20T10:14:15Z")

</div>

@sebavan Sorry to abuse of your time: do you know if it is possible to use a variable in the “base64String” of the albedoTexture?

If I use

`"base64String":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="`

it does work  
If I do

`var brownEyes="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII="`

and then, within the albedoTexture…

`"base64String": brownEyes`

it doesn’t.

Namely, I get a console error `"Unable to load from data"` and then the content of the mesh.

Since I’m converting them manually, would be easier to convert them all once and then use a reference.  
Thanks

---

<div class="post-metadata">

**Author:** ![Dr.Hell](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@Dr.Hell](https://forum.babylonjs.com/u/Dr.Hell)\
**Post date:** [September 20, 2021, 12:34pm UTC](https://forum.babylonjs.com/t/can-albedotexture-be-automatically-exported-in-base64-format/23960/6 "2021-09-20T12:34:52Z")

</div>

Ok, I can reply to myself regarding this last point, in case someone else needs help in future.

The problem happened because I converted directly the babylon mesh in a string, like this  
`var mesh:string='BABYLON FILE CONTENT';`  
and then called  
`BABYLON.SceneLoader.Append("", "data:"+mesh, scene, function () {});`

While this works, it creates the aforementioned problem when using variables within the mesh definition  
Changing it to

`var mesh:any=BABYLON FILE CONTENT; // now mesh is an object and I can use variable names within it`  
and then calling  
`BABYLON.SceneLoader.Append("", "data:"+JSON.stringify(mesh), scene, function () {});`

Everything worked!

---

<div class="post-metadata">

**Author:** ![JCPalmer](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jcpalmer/32/42_2.png) [@JCPalmer](https://forum.babylonjs.com/u/JCPalmer)\
**Post date:** [September 20, 2021, 1:26pm UTC](https://forum.babylonjs.com/t/can-albedotexture-be-automatically-exported-in-base64-format/23960/7 "2021-09-20T13:26:56Z")

</div>

The .babylon / JSON exporter in Blender can embed all texture types except for environment textures. It is a boolean custom property in World labeled `inline`. The tool tip give more info, but maybe changing it something `embed as base-64` for for 3.0.3 would stand out more.

 ![world](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/7/8/785a48d5620956a02650e3e5e1e68555f1340279.jpeg)
