How i built — Part 3 — Assets automation with Grunt

Dominic Mercier
Feb 19, 2014 · 3 min read

In the third post of the series, i will talk about the process of creating assets on If you haven’t read the previous post about the exploration module, i strongly suggest that you read it before reading this one, as it will introduce you to some of the concept behind the exploration module.

Image for post
Image for post


As you know, we had to split our panoramic images into pieces of 2048 x 2048 for retina display and 1024 x 1024 for standard resolution display. We also had to compress these images to ATF format to be compatible with Starling and use lower GPU memory.

With 23 locations across the projects and lots of round of iterations and corrections, i knew that we needed a way to automate this process to prevent human errors during one of the multiples operations required.

Grunt to the rescue

Image for post
Image for post

If you don’t know Grunt, i suggest you to read my posts about Grunt (Improve your workflow with GruntJS, Automatic spritesheet creation with GruntJS). Using Grunt, i was able to build simple plugins that would completely automate this process and make it 100% bullet proof.

As a starting point, i knew i would need these parameters in my plugin.

  • sources directory
  • output directory
  • retina (true | false)
  • atf format (desktop | ios)

With this in mind, i built a simple plugin that take care of splitting images into pieces, compress it to ATF and saving it into output directory.

Splitting panoramic into pieces

Here is the process behind splitting the panoramic images into smaller pieces.

  1. Get source image dimensions
  2. If RETINA = true, copy image to temporary folder as temporary image
  3. If RETINA = false, resize image by 50% and save it to temporary folder as temporary image
  4. Calculate the number of pieces required (n) by dividing image’s width with piece’s width (2048 for retina versus 1024 for standard)
  5. Crop piece i from temporary image using EasyImage
  6. Compress cropped image to ATF format into output folder
  7. Get back to step 5 until image is completely splitted

As you can see, it’s pretty simple. All i have to do next is to populate my Grunt file with all locations on the project. Here is simplified of what my Grunt file looks like:


I’ve submitted all Grunt plugins i’ve made in this project to GitHub. Feel free to clone and modify theses to better suit your needs.

  • fmm-zone: Create all types of assets used by exploration module using EasyImage and node-atf
  • fmm-atlas: Create image atlas (aka spritesheet) using TexturePacker command line tool
  • node-atf: NodeJS module to output ATF texture from PNG image using Adobe’s PNG2ATF command line tool. ** Update ** TexturePacker now export to ATF format. Check if this awesome tool better suit your needs and skills set.


Creating this process took me around 2 days but i estimate this automation process saved me about 4 to 5 days of work. The most valuable part of this was to bullet proof this process by removing unexpected human errors and ensure the same quality, locations after locations.

I hope you enjoy this post about automated assets creation with GruntJS on The complete Grunt file on the project create more than just explorations assets. This includes responsive images, spritesheets and more.

In the next post of the series, i will talk about Audio and Video modules in

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store