6 Replies Latest reply on Jun 30, 2015 1:51 PM by maurymountain

    Adding file formats to Generator




      I am interested in adding some other file formats to the newly added Generator feature in Photoshop CC, but have no idea where to start after looking at the installed scripts. I am also not the most experienced with this, so my lack of knowledge is probalby also blocking me


      What I want to do:


      - add TGA formats in 32 and 24 bit format based on the existence of an alpha channel

      - change where the image assets are saved to be in the same directory as the psd, not one directory lower in [filename] - assets folder.


      Have not had any luck adding TGA formats, again, unclear how to do this. Can see things happening in convert.js, however when trying to add a TGA entry to this, it fails (and deletes the assets folder).


      any help would be appreciated!

        • 1. Re: Adding file formats to Generator
          Dennis Kehrig

          Hello there!


          Merely getting some TGA support is very simple, just add "tga" to supportedExtensions in generator-image-assets/main.js.


          Now, to support something like ".tga24" and ".tga32" (rather than letting ImageMagick figure out the quality automatically), more is necessary. But first we need to find out how to get ImageMagick to do one or the other - I did not find a way to influence whether it adds an alpha channel to the TGA or not. Of course you could also use ImageMagick to convert the file to a PNG or something, and then convert that with a more specialized TGA writer, if that exists - more work still, but probably not that much.


          The important places are the function analyzeComponent in generator-image-assets/main.js (the variable supportedExtensions and futher below the validation of the quality setting) and generator-core/convert.js, which you already found.


          Does this help a little bit?


          Good luck!


          - Dennis

          • 2. Re: Adding file formats to Generator

            I added "tga", worked like a charm. If someone could figure out what needs to be added to make it either 24 or 32 so it exports with the alpha channel this will be amazing. Seriously. I'll pay for it if I have to...SERIOUSLY!

            • 3. Re: Adding file formats to Generator
              maurymountain Level 1

              Hey Dennis, applogies for not responding sooner -but thank you for this! Finally was able to get around to dig in, and got it working. Honestly, my biggest hurdle was actually finding where any of these files existsed, where i needed to put plugins, etc. None of the names any one uses on any sites actually match up to what exists on my machine. When you say generator-image-assets, all i have locally (without downloading anything, just looking to modify existing functionality) is "assets.generate." It wasn't until I watched a video where I then understood what to look for. I even went as far as learning how to create some custom plugins which will be handy someday!


              Will need to dig a bit deeper to figure out the 24/32 bit thing. Saving as a PNG and converting to TGA is not ideal, as PNGs save alpha information differently and it would not be compatible with TGA use. A TGA relies on RGB information to exist, and PNGs "lose" pixels if there is transparency. TGA alphas can be used in game engines and 3d software to provide transparency, and a ton of other applications since it is a 4th channel. You can copy of the red or green channel with some modifications into the Alpha, and append the channels in a different order (RGA  -> RGB, RBA -> RGB, BGA -> RGB, etc) to get new colors on the texture for a game asset, a cropped version of a logo or glow that you reposition in a shader, or a completely separate texture that is used in some other way.


              I did notice that generate assets does not play well with Adjustment Layers, they do not respect the group they live in, but affect all layer groups. You can get around it by creating a smartgroup out of the layers you want to be affected by the adjustment layer. Not the cleanest fix, but will get the job done.


              Thanks again for the info, was a big help!

              • 4. Re: Adding file formats to Generator
                hilukasz Level 1

                is there any more information on this? I would love to be able to do this as well.

                • 5. Re: Adding file formats to Generator
                  dVeller Level 1

                  I came across this thread and see the question is still un-answered and kind of been a while since there has been activity. However, I am also very interested in getting this to work for my team for some 3d texture work. I'm not a programmer but tried my best to get this to work.


                  I've attempted to add the tga quality to the to convert.js and have not gotten the tga flag to engage. If someone who has successfully added tga to their convert.js file i'd be very appreciative to anyone who would be willing to offer their bit of code. I did add the "tga" to main.js so I should be fine there.


                  Some of the previous comments made it seem so easy


                  • 6. Re: Adding file formats to Generator
                    maurymountain Level 1

                    Resurrecting this thread with some actual info


                    The process has changed slightly for CC 2015.


                    Close Photoshop

                    Open: \Program Files\Adobe\Adobe Photoshop CC 2015\Required\Plug-Ins\Generator\assets.generate\lib\parsermanager.js

                    search: supportedExtensions

                    add: "tga": true, in there. I put it after the gif one.


                    Start photoshop, your layer group can be named file.tga and it will save out a tga file. One awesome bit, if you have alpha on your layer (similar to a .png) it will save the alpha of the layer to the Alpha Channel. Didn't get to add 32/24 bit type inputs.


                    Some notes:

                    Generator now respects your document bounds, horray!

                    Adjustment Layers work appropriately within a group, however they still go through groups and affect all exports. EX: Group A (Hue/Sat - Colorize to Green), Group B (Gradient Map): When you have both layers visible, and Group A is above Group B in the stack, Group B will be exported with Group A's adjustment layer(s) - unless you clip-mask them.


                    I do not like the files saving in a sub directory off of the PSD, so I also edted filemanager.js in the same directory as above (deleted red strike through text below)


                    on line 270


                            if (this._config.hasOwnProperty("base-directory")) {

                                basePath = path.resolve(this._config["base-directory"], documentName + "-assets");

                            } else if (documentDirectory) {

                                basePath = path.resolve(documentDirectory, documentName + "-assets");

                            } else {

                                basePath = null;




                    Now... need to figure out how to get TGAs into the Quick Export menu!