# Error When Using CreateFromBase64String To Load TGA Image File

**URL:** <https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140>\
**Category:** Questions\
**Created:** [March 29, 2024, 6:31am UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140 "2024-03-29T06:31:41Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moriy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/moriy/32/30563_2.png) [@Moriy](https://forum.babylonjs.com/u/Moriy)\
**Post date:** [March 29, 2024, 6:31am UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/1 "2024-03-29T06:31:41Z")

</div>

Hi everyone，  
I plane to load texture from base64 data. I have a try to load them with CreateFromBase64String, but it always create a red-black texture. Does CreateFromBase64String support .tga type?

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/7/3/73a799b76acd0bdb5dc3fd39ffe8512fba4fa31f.jpeg)

> **[Babylon.js Playground](https://playground.babylonjs.com/#0VJRJS%234)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [March 29, 2024, 10:47am UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/2 "2024-03-29T10:47:46Z")

</div>

TGAs are not supported by browsers, so we can’t handle them (we use browser methods to load files).

You should try using PNG files instead, if your workflow allows.

---

<div class="post-metadata">

**Author:** ![Moriy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/moriy/32/30563_2.png) [@Moriy](https://forum.babylonjs.com/u/Moriy)\
**Post date:** [March 29, 2024, 12:33pm UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/3 "2024-03-29T12:33:50Z")

</div>

I find tga.ts in babylonjs/core, could it provide any help?

> <https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Misc/tga.ts>

I have a try to generate a blob url and load from it, it not work

> **[Babylon.js Playground](https://playground.babylonjs.com/#0VJRJS%238)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Moriy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/moriy/32/30563_2.png) [@Moriy](https://forum.babylonjs.com/u/Moriy)\
**Post date:** [March 29, 2024, 3:23pm UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/4 "2024-03-29T15:23:56Z")

</div>

This can work! 💖

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/b/ebdae4c88980046b07837ce27590310cbbb0433f.png)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [March 29, 2024, 4:23pm UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/5 "2024-03-29T16:23:04Z")

</div>

Yes we should be able to load tga if I remember correctly (on my phone so I could be wrong)

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [March 29, 2024, 8:02pm UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/6 "2024-03-29T20:02:23Z")

</div>

Ah, I didn’t remember we have a TGA loader!

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [March 29, 2024, 10:38pm UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/7 "2024-03-29T22:38:18Z")

</div>

I made a fix to let you specify the extension to load:  
[Allow CreateFromBase64String and LoadFromDataString to specifiy exten… by deltakosh · Pull Request #14932 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/14932)

Once merged this PG will work:  
[How to set independent materials for each side of a cuboid | Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#0VJRJS#14)

---

<div class="post-metadata">

**Author:** ![Moriy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/moriy/32/30563_2.png) [@Moriy](https://forum.babylonjs.com/u/Moriy)\
**Post date:** [April 2, 2024, 1:10am UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/8 "2024-04-02T01:10:40Z")

</div>

I find that Loader will throw a error when GLB contains .tga file. Is it the same problem with CreateFromBase64String? 😁

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [April 2, 2024, 9:29am UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/9 "2024-04-02T09:29:09Z")

</div>

I think gltf does not support TGA as a texture file format.

cc @bghgary

---

<div class="post-metadata">

**Author:** ![Moriy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/moriy/32/30563_2.png) [@Moriy](https://forum.babylonjs.com/u/Moriy)\
**Post date:** [April 2, 2024, 10:09am UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/10 "2024-04-02T10:09:27Z")

</div>

It is seems that FBX2GLTF tools can package TGA file into glb, and I used to use model-viewer to load glb file with tga.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [April 2, 2024, 10:24am UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/11 "2024-04-02T10:24:52Z")

</div>

According to the [spec](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#gltf-basics), only .png and .jpg are supported as texture formats.

I could not find an extension that would support TGA:

> <https://github.com/KhronosGroup/glTF/blob/main/extensions/README.md>

Let’s wait for @bghgary input, who will know for sure if TGA support is standard in gltf.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [April 2, 2024, 3:25pm UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/12 "2024-04-02T15:25:09Z")

</div>

TGA is not supported in glTF, sorry. It would be non-conformant to load TGA with glTF without an extension. Why use TGA?

---

<div class="post-metadata">

**Author:** ![Moriy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/moriy/32/30563_2.png) [@Moriy](https://forum.babylonjs.com/u/Moriy)\
**Post date:** [April 2, 2024, 3:51pm UTC](https://forum.babylonjs.com/t/error-when-using-createfrombase64string-to-load-tga-image-file/49140/13 "2024-04-02T15:51:57Z")

</div>

I plan to achieve a model-viewer with Babylonjs which can view model-file like fbx,max,mb.  
Old plan is converting them to fbx (autodesk api), next to glb (FBX2GLTF tools). In this way, I have to face glb with .gta image. New plan is port FBXLoader to Babylonjs that I can control the parse process and get more information from origin file (convert fbx to glb always lose many informations)
