# How to reduce size of texture in build?

**URL:** <https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835>\
**Category:** Questions\
**Created:** [October 10, 2022, 10:57am UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835 "2022-10-10T10:57:32Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ja\_Hve](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ja_hve/32/29942_2.png) [@Ja\_Hve](https://forum.defold.com/u/Ja_Hve)\
**Post date:** [October 10, 2022, 10:57am UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835/1 "2022-10-10T10:57:32Z")

</div>

i have started porting this [monster gemnerator](https://gamefromscratch.com/universal-sprite-sheet-character-creator/) for Defold.  
154 \* 30 kB images (png optimized for web) has after build 158 \* 10623 kB ( _generated_\*\*\*\*.texturec )  
How i can reduce texture file size in build?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 10, 2022, 10:59am UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835/2 "2022-10-10T10:59:28Z")

</div>

> [@Ja\_Hve](#):
>
> How i can reduce texture file size in build?

If you put all of the images in an atlas or generate a tilesource file you will be able to apply texture compression on it:

> **[Texture profiles in Defold](https://defold.com/manuals/texture-profiles/)**
>
> Defold supports automatic texture processing and compression of image data. This manual describes the available functionality.

---

<div class="post-metadata">

**Author:** ![Ja\_Hve](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ja_hve/32/29942_2.png) [@Ja\_Hve](https://forum.defold.com/u/Ja_Hve)\
**Post date:** [October 11, 2022, 6:01pm UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835/3 "2022-10-11T18:01:09Z")

</div>

problem is in build where png images are compiled to texture, all this job ( generate atlas and tilesources put property line in go.fabric)i have writed in python  
it look as low level work,

create map\<string,mem\>  
load all png images to mem buffer  
decode when is needed to dds  
use multitexture quad

job for stl  
i flused this project out of work

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [October 12, 2022, 6:36am UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835/4 "2022-10-12T06:36:38Z")

</div>

The easiest way to create an atlas is described in the documentation:

> **[Atlas manual](https://defold.com/manuals/atlas/)**
>
> This manual explains how Atlas resources work in Defold.

---

<div class="post-metadata">

**Author:** ![Ja\_Hve](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ja_hve/32/29942_2.png) [@Ja\_Hve](https://forum.defold.com/u/Ja_Hve)\
**Post date:** [October 12, 2022, 5:18pm UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835/5 "2022-10-12T17:18:23Z")

</div>

thank you for suport, bat i have 128 x spritesheets 700x300 pixel x rgba with 30kB mem size in png.  
in build is compiled to ziped VRAM texture? hardware compesion? so size is 4mega

---

<div class="post-metadata">

**Author:** ![Ja\_Hve](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ja_hve/32/29942_2.png) [@Ja\_Hve](https://forum.defold.com/u/Ja_Hve)\
**Post date:** [October 12, 2022, 5:45pm UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835/6 "2022-10-12T17:45:04Z")

</div>

look at images  
[https://www.bing.com/search?q=Universal-LPC-Spritesheet-Character-Generator](https://www.bing.com/search?q=Universal-LPC-Spritesheet-Character-Generator)

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 12, 2022, 9:55pm UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835/7 "2022-10-12T21:55:38Z")

</div>

> [@Ja\_Hve](#):
>
> in build is compiled to ziped VRAM texture? hardware compesion?

The images you put into an atlas will be converted into a texture resource in your game. The texture will be compressed if you are using texture compression. How much it will be compressed depends on how you have configured the texture compression (see previous link to the manual on texture compression). We use Basis Universal as the intermediate texture format and at runtime it will be converted to a platform specific compression format.

---

<div class="post-metadata">

**Author:** ![Ja\_Hve](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ja_hve/32/29942_2.png) [@Ja\_Hve](https://forum.defold.com/u/Ja_Hve)\
**Post date:** [October 13, 2022, 1:25pm UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835/8 "2022-10-13T13:25:41Z")

</div>

thanks  
i had incorrect question.  
so it is posible in build export png file( no texture)  
and in runtime create texture ?  
from gideros:

```lua
local bmp = Bitmap.new(Texture.new("ball.png", true))
bmp:setPosition(100, 100)
stage:addChild(bmp)

```

```lua

```

---

<div class="post-metadata">

**Author:** ![Ja\_Hve](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ja_hve/32/29942_2.png) [@Ja\_Hve](https://forum.defold.com/u/Ja_Hve)\
**Post date:** [October 13, 2022, 1:45pm UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835/9 "2022-10-13T13:45:09Z")

</div>

from start  
i wont build roqu3like rpg with generated content - maze, srory, quests , npc, enemy. exac5ly i dont know in build time what wil used. i had more then 100 spritesheets wih 30 kb size after build i will have 100 textures with 4mb. add all preeteshet to atlas dont solve problem becse texture size is limited( spriteshets has 700 x 300 pixels) . and BTW texture compile with compresiontime is terrible.  
you see difference 30kb_100 vs 4mb_100?

---

<div class="post-metadata">

**Author:** ![Ja\_Hve](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ja_hve/32/29942_2.png) [@Ja\_Hve](https://forum.defold.com/u/Ja_Hve)\
**Post date:** [October 13, 2022, 1:46pm UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835/10 "2022-10-13T13:46:01Z")

</div>

soory i write on mobile and english is c3 level

---

<div class="post-metadata">

**Author:** ![Ja\_Hve](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/ja_hve/32/29942_2.png) [@Ja\_Hve](https://forum.defold.com/u/Ja_Hve)\
**Post date:** [October 13, 2022, 1:50pm UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835/11 "2022-10-13T13:50:35Z")

</div>

and plese dont spawn own forum wiIth BFU RTFM, you can have question to.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 13, 2022, 10:23pm UTC](https://forum.defold.com/t/how-to-reduce-size-of-texture-in-build/71835/12 "2022-10-13T22:23:45Z")

</div>

> [@Ja\_Hve](#):
>
> and plese dont spawn own forum wiIth BFU RTFM, you can have question to.

I have no idea what you are saying here, sorry.

> [@Ja\_Hve](#):
>
> so it is posible in build export png file( no texture)  
> and in runtime create texture ?  
> from gideros:

Defold is not designed for this kind of scenario. In Defold we prefer to know about the data used in the game up-front. It is much more performant to create textures at build time than at run-time.

> [@Ja\_Hve](#):
>
> add all preeteshet to atlas dont solve problem becse texture size is limited

Yes, there is obviously a limit to have many images you can keep in memory at once. This is not something unique to Defold. You need to manage memory usage somehow. You can’t load 100’s of individual spritesheets either. You need to decide what to load and when. In Defold you can have many atlases or tilesources too, but not necessarily have them loaded all at once. For factory components there is an option to lazy load the resource using factory.load(). This will help you manage resource use if you have more resources than you can have in memory all at once.
