{"id":"image-x-tga","mimeType":"image/x-tga","name":"Truevision TGA (Legacy MIME Alias)","shortName":"TGA","category":"Raster Graphics \u0026 Textures","extensions":[".tga",".icb",".vda",".vst"],"description":"The image/x-tga MIME type is a common unofficial alias for the Truevision TGA (TARGA) image format. Created in 1984 by Truevision Inc. for their early video capture boards, TGA was a pioneering raster format supporting 24-bit true color and a 32-bit alpha channel on PCs. Its straightforward byte structure, native transparency, and fast, lossless Run-Length Encoding (RLE) compression made it an industry standard for 3D animation, video editing, and video game textures throughout the 1990s and 2000s. Although standard MIME validators typically prefer 'image/tga' or 'image/x-targa', 'image/x-tga' is frequently encountered in legacy systems, game engine asset pipelines, and older web servers.","seo":{"title":"image/x-tga MIME Type | Developer Reference for TGA Format","description":"Complete reference for the image/x-tga MIME type: Truevision TGA format, 3D video game textures, TARGA history, alpha channels, and file detection.","faqs":[{"question":"What is the difference between image/x-tga and image/x-targa?","answer":"There is no difference in the underlying file. Both MIME types refer to the Truevision TGA (TARGA) image format. 'image/x-targa' and 'image/tga' are more commonly recognized by modern systems, while 'image/x-tga' is an older alias often generated by legacy software."},{"question":"Why do video games still use TGA files?","answer":"TGA files are structurally very simple, making them incredibly fast for a game engine to decode and load into memory (VRAM). Their native support for an 8-bit alpha channel also ensures perfect transparency masking for 3D textures, decals, and foliage."},{"question":"How do I detect a TGA file programmatically?","answer":"Original TGA 1.0 files lacked a header signature. However, the TGA 2.0 specification introduced a file footer. You can reliably detect a TGA 2.0 file by reading the last 18 bytes of the file, which will contain the ASCII string 'TRUEVISION-XFILE.'."}]},"index":{"compression":["Uncompressed","Run-Length Encoding (RLE)"],"browserSupport":{"score":1,"label":"None"},"commonUses":["Video Game 3D Textures and Materials","3D Rendering and Animation Sequences","Legacy Video Production Workflows"]},"technical":{"magicBytes":{"hex":"54 52 55 45 56 49 53 49 4F 4E 2D 58 46 49 4C 45 2E 00 (At the end of the file)","ascii":"TRUEVISION-XFILE.\\x00"},"container":"Truevision TGA Footer/Header","compressionAlgorithm":["None","RLE"],"colorDepth":["8-bit (Grayscale or Indexed)","16-bit (High Color)","24-bit (True Color)","32-bit (True Color with Alpha Channel)"],"transparency":true,"animation":false,"metadata":{"exif":false,"xmp":false,"iccProfile":false},"alphaChannel":true,"progressiveLoading":false,"hdrSupport":false},"history":{"developer":"Truevision Inc.","released":"1984","specification":"Truevision TGA File Format Specification (v2.0 released in 1989)"},"browserSupport":{"chrome":false,"chromeVersion":"None","firefox":false,"firefoxVersion":"None","safari":false,"safariVersion":"None","edge":false,"edgeVersion":"None","internetExplorer":false},"softwareSupport":[{"name":"Adobe Photoshop","logo":""},{"name":"Blender / Maya / 3ds Max","logo":""},{"name":"Unreal Engine / Unity","logo":""},{"name":"ImageMagick","logo":"image-magic.webp"}],"conversion":{"convertTo":["png","tiff","jpeg","bmp"],"convertFrom":["png","tiff","psd"]},"developer":{"httpHeaders":[{"header":"Content-Type","value":"image/x-tga"},{"header":"Content-Type","value":"image/x-targa"}],"htmlAccept":"image/x-tga, image/x-targa, .tga","fileDetection":["Because TGA 1.0 files do not have a magic number at the beginning of the file, MIME detection strictly by reading offset 0 is impossible.","The TGA 2.0 specification introduced a file footer. To detect a TGA 2.0 file, seek to the end of the file. The last 26 bytes make up the footer. Bytes 8 through 23 of this footer (18 bytes from EOF) contain the ASCII signature 'TRUEVISION-XFILE.' followed by a null terminator.","When encountering 'image/x-tga' in file uploads, it is recommended to normalize the MIME type string in your database to 'image/tga' or 'image/x-targa' to align with broader conventions."]},"prosCons":{"pros":["Incredibly simple byte layout allows developers to write custom loaders and exporters in a few dozen lines of code, bypassing the need for heavy external libraries","Native support for 8-bit alpha channels ensures flawless transparency masking for real-time 3D rendering","Fast, predictable RLE decoding requires almost no CPU overhead compared to DEFLATE (PNG) or DCT (JPEG)"],"cons":["RLE compression is relatively weak by modern standards, resulting in large file sizes","Lacks a standard magic byte header at the beginning of the file, making file-sniffing unreliable for older v1.0 files","Zero support in web browsers; must be converted to PNG or WebP for web delivery"]},"specifications":{"url":"https://www.dca.fee.unicamp.br/~martino/disciplinas/ea978/tgaffs.pdf","rfc":"","mimeAliases":["image/tga","image/x-targa","application/tga"]},"developerSnippets":{"python":"import os\n# To reliably detect TGA 2.0, you must check the footer at the end of the file\nwith open('texture.tga', 'rb') as f:\n    f.seek(-18, os.SEEK_END)\n    signature = f.read(17)\n    is_tga = signature == b'TRUEVISION-XFILE.'\n    print('Is TGA 2.0:', is_tga)","nodejs":"const fs = require('fs');\n// Seeking to the end of the file to check for the TGA 2.0 footer\nconst stats = fs.statSync('texture.tga');\nif (stats.size \u003e= 18) {\n    const buffer = Buffer.alloc(17);\n    const fd = fs.openSync('texture.tga', 'r');\n    fs.readSync(fd, buffer, 0, 17, stats.size - 18);\n    fs.closeSync(fd);\n    const isTGA = buffer.toString('ascii') === 'TRUEVISION-XFILE.';\n    console.log('Is Truevision TGA v2:', isTGA);\n}","go":"import (\n    \"os\"\n)\n// Native Go HTTP detection will not recognize TGA.\n// You must read the end of the file:\n// file, _ := os.Open(\"texture.tga\")\n// stat, _ := file.Stat()\n// buf := make([]byte, 17)\n// file.ReadAt(buf, stat.Size()-18)\n// isTGA := string(buf) == \"TRUEVISION-XFILE.\"","php":"$mime = mime_content_type('texture.tga');\necho $mime; // May return 'image/x-tga', 'image/x-targa', or 'application/octet-stream' depending on OS magic definitions and whether it is a v1.0 or v2.0 file."},"relatedFormats":["png","bmp","tiff","psd"]}
