{"id":192,"date":"2009-10-22T14:20:17","date_gmt":"2009-10-22T13:20:17","guid":{"rendered":"http:\/\/david.buttress.me.uk\/blog\/?p=192"},"modified":"2009-10-22T14:20:17","modified_gmt":"2009-10-22T13:20:17","slug":"save-as-tga-photoshop-script","status":"publish","type":"post","link":"http:\/\/david.buttress.me.uk\/blog\/?p=192","title":{"rendered":"Save as TGA Photoshop Script"},"content":{"rendered":"<p>Our pipeline tends to work best when using TGA files for textures (it does work with PSDs but to be honest I don&#8217;t really trust it :)) However I&#8217;ve always found it a bit cumbersome to actually save out a copy from Photoshop, requiring you to &#8216;Save As&#8230;&#8217;, pick the file type, fix the name, yes I do want to overwrite, etc.<\/p>\n<p>I figured a nice little script would streamline this considerbly.\u00a0 And as an added bonus it&#8217;s possible to execute a script through an action, which also allows you to assign a keyboard shortcut to it. With this setup I just hit F2 and I get a tga of the current document, no interaction at all, it just spits it out without disrupting anything.<\/p>\n<p>There&#8217;s just one thing to watch out for; by design, it will overwrite the old tga file without warning, so you need to make sure that the tgas are treated as a purely automatic intermediate step and shouldn&#8217;t be hand altered.<\/p>\n<p><br class=\"spacer_\" \/><\/p>\n<p>Just save this code to a .jsx file, create a new action and execute the script while it&#8217;s recording (File -&gt; Scripts -&gt; Browse&#8230;).<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar docName = app.activeDocument.name\r\nvar docPath = app.activeDocument.path.fullName\r\n\r\nvar splitName = docName.split(&quot;.&quot;)\r\n\r\nvar fileName = splitName[0]\r\n\r\nfor (i=1; i&lt;(splitName.length - 1); i++)\r\n{\r\n\tfileName = fileName.concat( &quot;.&quot;, splitName[i] )\r\n}\r\n\r\nvar newFileName = docPath.concat( &quot;\/&quot;, fileName, &quot;.tga&quot;)\r\n\r\ntargaFile = new File( newFileName )\r\ntargaSaveOptions = new TargaSaveOptions()\r\ntargaSaveOptions.resolution = TargaBitsPerPixels.THIRTYTWO\r\ntargaSaveOptions.alphaChannels = true\r\n\r\napp.activeDocument.saveAs(targaFile, targaSaveOptions, true, Extension.LOWERCASE)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Our pipeline tends to work best when using TGA files for textures (it does work with PSDs but to be honest I don&#8217;t really trust it :)) However I&#8217;ve always found it a bit cumbersome to actually save out a copy from Photoshop, requiring you to &#8216;Save As&#8230;&#8217;, pick the file type, fix the name, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"http:\/\/david.buttress.me.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/192"}],"collection":[{"href":"http:\/\/david.buttress.me.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/david.buttress.me.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/david.buttress.me.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/david.buttress.me.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=192"}],"version-history":[{"count":6,"href":"http:\/\/david.buttress.me.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/192\/revisions"}],"predecessor-version":[{"id":198,"href":"http:\/\/david.buttress.me.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/192\/revisions\/198"}],"wp:attachment":[{"href":"http:\/\/david.buttress.me.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/david.buttress.me.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/david.buttress.me.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}