{"id":"image-ktx","mimeType":"image/ktx","name":"Khronos Texture","shortName":"KTX","category":"3D \u0026 Textures","extensions":[".ktx"],"description":"Khronos Texture (KTX) is a lightweight container format designed to store texture data for real-time 3D graphics applications using OpenGL, OpenGL ES, and Vulkan. It supports 1D, 2D, 3D, cubemap, and array textures, and can encapsulate pre-compressed GPU texture formats (like ASTC, ETC2, and BCn) for immediate, zero-copy uploading to the graphics pipeline.","seo":{"title":"image/ktx MIME Type | Complete Developer Reference \u0026 Magic Bytes","description":"Complete reference for the image/ktx MIME type: magic bytes, software support, HTTP headers, developer snippets, and technical specifications for Khronos Texture files.","faqs":[{"question":"What is the difference between KTX and standard image formats like PNG or JPEG?","answer":"Standard images require the CPU to decompress them into raw pixels before they can be uploaded to the GPU, causing loading hitches and high memory usage. KTX files store pre-compressed GPU formats (like ASTC or BCn) that are uploaded directly to the GPU without CPU decoding, significantly reducing memory footprint and load times."},{"question":"What is the magic byte for a KTX file?","answer":"KTX 1.1 files begin with a 12-byte identifier: AB 4B 54 58 20 31 31 BB 0D 0A 1A 0A. This roughly translates to '«KTX 11»' followed by carriage return, line feed, substitute, and line feed characters."},{"question":"Can I use KTX textures in a web browser?","answer":"Native HTML \u003cimg\u003e tags do not support KTX. However, they are heavily used in WebGL and WebGPU applications via JavaScript 3D engines (like Three.js or Babylon.js) which parse the KTX container and feed the compressed texture data directly to the graphics API."}]},"index":{"compression":["Uncompressed","GPU Compressed (ASTC, ETC, BCn, PVRTC)"],"browserSupport":{"score":1,"label":"None (WebGL via JS only)"},"commonUses":["Real-time 3D Graphics","WebGL / WebGPU Applications","Mobile Games","Virtual/Augmented Reality (VR/AR)"]},"technical":{"magicBytes":{"hex":"AB 4B 54 58 20 31 31 BB 0D 0A 1A 0A","ascii":"«KTX 11»\\r\\n\\x1A\\n"},"container":"KTX (Khronos Texture 1.1)","compressionAlgorithm":["ASTC","ETC1 / ETC2","BCn (DXT)","PVRTC","Basis Universal (in KTX2)"],"colorDepth":["8-bit","16-bit","32-bit (Integer/Float)"],"transparency":true,"animation":false,"metadata":{"exif":false,"xmp":false,"iccProfile":false},"alphaChannel":true,"progressiveLoading":false,"hdrSupport":true},"history":{"developer":"Khronos Group","released":"2010","specification":"Khronos KTX File Format Specification"},"browserSupport":{"chrome":false,"chromeVersion":"None","firefox":false,"firefoxVersion":"None","safari":false,"safariVersion":"None","edge":false,"edgeVersion":"None","internetExplorer":false},"softwareSupport":[{"name":"Three.js (with KTXLoader)","logo":""},{"name":"Babylon.js","logo":""},{"name":"Compressonator (AMD)","logo":""},{"name":"PVRTexTool (PowerVR)","logo":""},{"name":"ImageMagick","logo":"image-magic.webp"}],"conversion":{"convertTo":["ktx2","png","dds","tga"],"convertFrom":["png","jpeg","tga","dds","exr"]},"developer":{"httpHeaders":[{"header":"Content-Type","value":"image/ktx"}],"htmlAccept":"image/ktx, .ktx","fileDetection":["Check the first 12 bytes for the KTX signature (AB 4B 54 58 20 31 31 BB 0D 0A 1A 0A)","Parse the 64-byte header to determine endianness, glType, glFormat, and pixel dimensions"]},"prosCons":{"pros":["Enables direct-to-GPU texture uploading, drastically reducing load times and CPU overhead in 3D applications","Supports complex texture types natively (mipmaps, cubemaps, 3D volumes, texture arrays)","Standardized across major Khronos APIs (OpenGL, Vulkan, WebGL) unlike vendor-specific formats like DDS"],"cons":["Requires custom JavaScript loaders to parse and display on the web","Zero native support in consumer image viewers or 2D photo editing software","Format fragmentation: a KTX file containing an ASTC payload will fail to render on hardware that only supports BCn compression (KTX2 and Basis Universal solve this)"]},"specifications":{"url":"https://registry.khronos.org/KTX/specs/1.0/ktxspec.v1.html","rfc":"RFC 9219","mimeAliases":["image/x-ktx"]},"developerSnippets":{"python":"import magic\nprint(magic.from_file('texture.ktx', mime=True)) # May output 'image/ktx' or 'image/x-ktx'","nodejs":"const FileType = require('file-type');\nconst type = await FileType.fromFile('texture.ktx');\nconsole.log(type?.mime); // Outputs 'image/ktx'","go":"import \"net/http\"\n// Requires checking the specific 12-byte prefix: bytes.HasPrefix(buf, []byte{0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A})","php":"$mime = mime_content_type('texture.ktx');\necho $mime; // Standard systems may map this to application/octet-stream"},"relatedFormats":["ktx2","dds","png"]}
