{"id":"image-ktx2","mimeType":"image/ktx2","name":"Khronos Texture 2.0","shortName":"KTX2","category":"3D \u0026 Textures","extensions":[".ktx2"],"description":"Khronos Texture 2.0 (KTX2) is a next-generation container format for GPU textures. It significantly improves upon the original KTX format by natively integrating Basis Universal compression (ETC1S and UASTC) and Zstandard (zstd) supercompression. This allows a single KTX2 file to be transcoded at runtime into the optimal compressed texture format for any target GPU (desktop or mobile), eliminating texture fragmentation.","seo":{"title":"image/ktx2 MIME Type | Complete Developer Reference \u0026 Magic Bytes","description":"Complete reference for the image/ktx2 MIME type: magic bytes, software support, HTTP headers, developer snippets, and technical specifications for Khronos Texture 2.0 files.","faqs":[{"question":"What is the difference between KTX and KTX2?","answer":"KTX (v1.1) stored textures in a specific hardware format (like ASTC or BCn), meaning developers often had to ship multiple versions of the same texture for different devices. KTX2 integrates Basis Universal compression, allowing a single file to be dynamically transcoded at runtime into whatever native format the host GPU prefers, vastly reducing application bundle sizes."},{"question":"What is the magic byte for a KTX2 file?","answer":"KTX2 files begin with a 12-byte identifier: AB 4B 54 58 20 32 30 BB 0D 0A 1A 0A. This translates to '«KTX 20»' followed by carriage return, line feed, substitute, and line feed characters."},{"question":"How is KTX2 used on the web?","answer":"While not supported natively by HTML \u003cimg\u003e tags, KTX2 is widely used in WebGL and WebGPU applications (via engines like Three.js and Babylon.js) and is the standard highly-compressed texture format for glTF 3D models (via the KHR_texture_basisu extension)."}]},"index":{"compression":["Basis Universal (ETC1S / UASTC)","Zstandard (zstd) Supercompression","Uncompressed"],"browserSupport":{"score":1,"label":"None (WebGL via JS only)"},"commonUses":["glTF 3D Models (KHR_texture_basisu)","WebGPU and WebGL Applications","Game Engines (Unity, Unreal, Godot)","Augmented and Virtual Reality (AR/VR)"]},"technical":{"magicBytes":{"hex":"AB 4B 54 58 20 32 30 BB 0D 0A 1A 0A","ascii":"«KTX 20»\\r\\n\\x1A\\n"},"container":"KTX 2.0","compressionAlgorithm":["ETC1S","UASTC","Zstandard (zstd)","Raw GPU Formats (ASTC, BCn)"],"colorDepth":["8-bit","16-bit","32-bit (Float)"],"transparency":true,"animation":false,"metadata":{"exif":false,"xmp":false,"iccProfile":false},"alphaChannel":true,"progressiveLoading":false,"hdrSupport":true},"history":{"developer":"Khronos Group","released":"2021","specification":"Khronos KTX 2.0 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 (KTX2Loader)","logo":""},{"name":"Babylon.js","logo":""},{"name":"Blender","logo":""},{"name":"Khronos toktx CLI Tool","logo":""},{"name":"Godot Engine","logo":""}],"conversion":{"convertTo":["png","jpeg","ktx","dds"],"convertFrom":["png","jpeg","exr","hdr","tga"]},"developer":{"httpHeaders":[{"header":"Content-Type","value":"image/ktx2"}],"htmlAccept":"image/ktx2, .ktx2","fileDetection":["Check the first 12 bytes for the KTX 2.0 signature (AB 4B 54 58 20 32 30 BB 0D 0A 1A 0A)","Parse the Data Format Descriptor (DFD) block to determine the internal compression payload (e.g., ETC1S or UASTC)"]},"prosCons":{"pros":["Universal hardware compatibility: write once, transcode anywhere to the target GPU's preferred format (ASTC, BC7, PVRTC, etc.)","Drastically reduces transmission size over networks thanks to Basis Universal and Zstandard supercompression","Seamless integration with the glTF ecosystem for optimized 3D asset delivery"],"cons":["Requires WebAssembly (Wasm) decoders and JavaScript loaders for web viewing, increasing initial application payload slightly","Encoding textures into high-quality Basis Universal UASTC can be computationally intensive and slow","Zero support in traditional 2D image viewers or native OS previews"]},"specifications":{"url":"https://registry.khronos.org/KTX/specs/2.0/ktxspec.v2.html","rfc":"RFC 9219","mimeAliases":[]},"developerSnippets":{"python":"import magic\nprint(magic.from_file('model_texture.ktx2', mime=True)) # May output 'image/ktx2' if magic db is updated","nodejs":"const FileType = require('file-type');\nconst type = await FileType.fromFile('model_texture.ktx2');\nconsole.log(type?.mime); // Outputs 'image/ktx2'","go":"import \"net/http\"\n// Requires custom byte checking for the KTX 2.0 header: bytes.HasPrefix(buf, []byte{0xAB, 0x4B, 0x54, 0x58, 0x20, 0x32, 0x30, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A})","php":"$mime = mime_content_type('model_texture.ktx2');\necho $mime; // Standard setups will often resolve to application/octet-stream without custom magic rules"},"relatedFormats":["ktx","dds"]}
