# How to dynamically create TextureAtlases from computer directory

**URL:** <https://phaser.discourse.group/t/how-to-dynamically-create-textureatlases-from-computer-directory/459>\
**Category:** Phaser 2 / CE\
**Created:** [December 24, 2018, 2:31pm UTC](https://phaser.discourse.group/t/how-to-dynamically-create-textureatlases-from-computer-directory/459 "2018-12-24T14:31:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![damager](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@damager](https://phaser.discourse.group/u/damager)\
**Post date:** [December 24, 2018, 2:31pm UTC](https://phaser.discourse.group/t/how-to-dynamically-create-textureatlases-from-computer-directory/459/1 "2018-12-24T14:31:43Z")

</div>

i wonder how to create N count of textureAtlases from directory and save them into it. Can i do this via TS(JS) or it’s easier to use something else? Thanks)

---

<div class="post-metadata">

**Author:** ![nazimboudeffa](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/nazimboudeffa/32/282_2.png) [@nazimboudeffa](https://phaser.discourse.group/u/nazimboudeffa)\
**Post date:** [December 24, 2018, 2:46pm UTC](https://phaser.discourse.group/t/how-to-dynamically-create-textureatlases-from-computer-directory/459/2 "2018-12-24T14:46:09Z")

</div>

Do you mean a method to pack textures into one file like [Texture Packer](https://www.codeandweb.com/texturepacker)

---

<div class="post-metadata">

**Author:** ![damager](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@damager](https://phaser.discourse.group/u/damager)\
**Post date:** [December 24, 2018, 3:08pm UTC](https://phaser.discourse.group/t/how-to-dynamically-create-textureatlases-from-computer-directory/459/3 "2018-12-24T15:08:11Z")

</div>

Not exactly, I need more “handcraft” decision. I just don’t know software or programming language that allow me to make a script that take N images and for each create another image(texture atlas) in the same directory with modified name. I want to cut images into puzzle pieces but i have a lot of them and i can’t to do it manually.

---

<div class="post-metadata">

**Author:** ![nazimboudeffa](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/nazimboudeffa/32/282_2.png) [@nazimboudeffa](https://phaser.discourse.group/u/nazimboudeffa)\
**Post date:** [December 24, 2018, 3:17pm UTC](https://phaser.discourse.group/t/how-to-dynamically-create-textureatlases-from-computer-directory/459/4 "2018-12-24T15:17:34Z")

</div>

You can do it with Texture Packer by creating a texture atlas file with json just by dropping your folder into the software

 ![2018-12-24_16-10-32](https://global.discourse-cdn.com/free1/uploads/phaser1/original/1X/c0d8299ab3e2a8880a145f669f34bb86f99388f2.png)

---

<div class="post-metadata">

**Author:** ![damager](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@damager](https://phaser.discourse.group/u/damager)\
**Post date:** [December 24, 2018, 3:26pm UTC](https://phaser.discourse.group/t/how-to-dynamically-create-textureatlases-from-computer-directory/459/5 "2018-12-24T15:26:08Z")

</div>

I can’t because i need to modify(crop and add upper texture etc.) images with custom settings. There is no program that can solve it. I’m just wonder how can i do this.

---

<div class="post-metadata">

**Author:** ![alb](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/alb/32/311_2.png) [@alb](https://phaser.discourse.group/u/alb)\
**Post date:** [December 25, 2018, 3:12am UTC](https://phaser.discourse.group/t/how-to-dynamically-create-textureatlases-from-computer-directory/459/6 "2018-12-25T03:12:21Z")

</div>

It depends on the exact details of your project but I would use imagemagick for this.  
I use Mac and Linux so i’d write a Bash script to loop over the files, create a new directory for each one and call imagemagick to crop it into new files.

Then you’d have several puzzle pieces in each new directory.

I think Texture Packer has command line tools you can use to pack each directory into a new texture atlas.

I’m sure there are many other ways as well but I hope that gives you an idea.

---

<div class="post-metadata">

**Author:** ![damager](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@damager](https://phaser.discourse.group/u/damager)\
**Post date:** [December 25, 2018, 3:19pm UTC](https://phaser.discourse.group/t/how-to-dynamically-create-textureatlases-from-computer-directory/459/7 "2018-12-25T15:19:05Z")

</div>

Thanks for answer, i guess that Imagemagick can help me with it) I need a lot of stuff to learn about Imagemagick)
