IMG archive

From GTAModding
Jump to: navigation, search
GTA's most commonly used archive files are cd images, known by the extension .img. They have a very simple format and currently exist in multiple versions.


The format reflects sectors of CD-ROMs, improving I/O speed on the storage media. Every file contained in the img archive must be sector aligned, where the size of each sector is 2048 bytes. Thus values for offset and size have to be multiplied by 2048. This means that even a file with only 123 byte content will take up 2 KiB in the archive.

The format is divided between directory entries, which contains information about the actual files in the img archive, and the actual files, which are stored (usually) unsorted, uncompressed and linear (no directory tree).

Directory entries should be in the same order as the files are stored, and there should not be any empty block between files. This is because the game might read more than one file with a single system call. By not following this rule, the game might get unstable.

Version 1 - GTA III & VC

In this version, the directory and the raw files are stored in separate files, the directory entries are stored in a .dir and the content pointed by the directory in the .img itself.

The directory archive (.dir) must have the same name as the .img archive, except for the extension. The directory archive is pretty simple, it contains no header, just the following structure repeated until the end of the file.

Directory Entry

Size of 32 bytes

 4 byte - DWORD 	- Offset (in sectors)
 4 byte - DWORD 	- Size (in sectors)
24 byte - CHAR[24]	- Name of the file (null terminated)

The total number of entries can be found by dividing the size of the .dir file by 32.

The .img file itself has no special structure or header, just all the files pointed by the directory.

This format was also used in the PC version of Bully: Scholarship Edition.


The XBOX versions of GTA III and GTA Vice City use lzo1x-999 compression on TXD and DFF files.

Version 2 - GTA SA

Introduced with GTA San Andreas, combines the directory entries (.dir) and raw files (.img) into one .img file. The directory has the same format as in version 1, but is located at the beginning of the archive. File offsets are relative to the start of the whole archive, not to the end of the file list.


Size of 8 bytes

4 byte - CHAR[4]	- “VER2”
4 byte - DWORD		- Number Of Entries

Followed by the header, there are the directory entries, containing information about the files in the archive.

Directory Entry

Size of 32 bytes

 4 byte - DWORD 	- Offset (in sectors)
 2 byte - WORD		- Size (in sectors)
 2 byte - WORD		- Streaming Size (in sectors) (always 0)
24 byte - CHAR[24]	- Name of the file (null terminated)

The streaming size is how many actual sectors the file takes in memory. If streaming size is 0, size will be used as streaming size. The stock img files never used streaming size (thus always 0), it's believed that this mechanism would be used for compression of files, but it never made it's way into production.

A major drawback of this format is the complicated extendability. If you have to add many files, it might happen that you run out of space for the directory, and have to move the first file(s) to the end.

Version 3 - GTA IV

GTA IV introduced yet another .img file format. Not only the format is new, also there can be encrypted archive headers (see below). The internal IMG parser of the game works with 2 kb buffers, which means that the 2 kb bounds from earlier versions (sectors) are still present, yet optional.

IMG Header

The header of an unencrypted file always has a size of 20 bytes.

4 byte - DWORD      - Identifier (0xA94E2A52 if the archive is not encrypted)
4 byte - DWORD      - Version (always 3, if not the format would be differ)
4 byte - DWORD      - Number of Items
4 byte - DWORD      - Table Size (in bytes)
2 byte - WORD       - Size of Table Items (needs to be always 0x10)
2 byte - WORD       - Unknown

IMG Table

The table holds information about the items. Each item header has a size of 16 bytes .

4 byte - DWORD      - Itemsize (in bytes)
4 byte - DWORD      - Resource type
4 byte - DWORD      - Offset (in sectors)
2 byte - WORD       - Used Blocks
2 byte - WORD       - Padding

Item Names' length will be calculate as :

Table Size - (Number of Items * Item Size)

Next that string will be split by '\x0'

A resource type is identified by the 4b DWORD value:

  • 0x01: Generic
  • 0x08: Texture archive
  • 0x20: Bounds
  • 0x6E: Model file
  • 0x24: xpfl


The header and directory (table) of IMG archives can be encrypted. This is usually the case if the 4 byte identifier at the start of the file seems invalid. Decryption is done via 16 repetitions of AES-128 in ECB mode.

Additional archives

It is possible to add additional IMG archives to the current default ones. The following examples are lines that can be added anywhere in either the default.dat or gta*.dat files.


Where FOO can be any name. The FOO.IMG (and FOO.DIR for GTA III and Vice City) must be created and placed within the ..\models folder in these examples. This method is primarily used for modifying version 2 of San Andreas, as well as for storing assets (models/textures/etc.) used in total conversions.

By default GTA San Andreas is able to load max of 8 archives (3 standard archives gta3.img, gta_int.img, player.img and 5 archives defined within default.dat or gta.dat). GTA VC is able to load max of 8 archives (one archive is hard-coded to be loaded - gta3.img) too. Using more than 8 archives crashes the game, although this can be fixed with fastman92's IMG Limit Adjuster.


GTA III Vice City ImgEd – by Dan Strandberg
GTA III Vice City San Andreas GTA 4 IMG Manager – by xmen
San Andreas GTA Net GTAGarage: Spark – by aru
GTA III Vice City San Andreas IMG Tool – by Spooky
GTA III Vice City San Andreas G-IMG – by REspawn
GTA III Vice City San Andreas GTA Net GTAForums: fastman92 IMG Console – by fastman92
Vice City San Andreas GTA Net GTAForums: IMG & Stream Limit Adjuster – by fastman92
GTA LCS GTA VCS Post.png GTAForums: GTA Stories IMG Tool – by HackMan128
GTA 4 SparkIV – by aru
GTA 4 OpenIV – by GooD-NTS
GTA 4 Shadow-Mapper – by Prince-Link


Version 2 only

Version 3 only

v · d · e
GTA 4 Grand Theft Auto IV
File Formats.dat.gxt.ide.img.ipl.nod.sco.rpf.rrr.wad.wbd/.wbn.wdd.wdr.wft.whm.wpl.wtd
DocumentationAudioBink VideoCryptographyCutscenesImage listingMap ListingNative functionsPathsScenariosVTableWeapons
ToolsASI LoaderENBSeriesG-TextureGIMSIV NeedleOpenIVScoclSparkIVXLiveLessWPL ManagerX Mod Installer
AliceC++ Script Hook.NET Script Hook
TutorialsImporting Textures with OpenIVImporting Textures with SparkIV
ModificationsGostown IVFour MultiplayerIV Multiplayer
Useful linksCommunity portalDiscussion forumsGTA IV Modding ForumMods on
v · d · e
San Andreas Grand Theft Auto: San Andreas
File Formats.col.cfg.cut.dff.dat.fxp.gxt.ide.ifp.img.iplnodes*.dat.ped.rep.rrr.scm.set.txd
DocumentationAudioCryptographyCutscenesGame memoryHandling.cfgMap ListingMission PacksOpcodesPathsReplaysSavesScripts
ToolsCLEOCollision File Editor IIENBSeriesG-ToolsIMG ToolLimit AdjusterMap EditorMod LoaderSan Andreas Audio ToolkitSanny BuilderTXD Workshop
TutorialsSan Andreas v2.0 ModdingHow to create a missionHow to create a threadHow to use Map EditorVehicle Mod Installation
ModificationsDesign Your Own MissionGostown ParadiseGTA: UnitedMyriad Islands
MultiplayergtaTournamentMulti Theft AutoSan Andreas Multiplayer(more...)
Useful linksCommunity portalDiscussion forumsMods on GTAGarage.comOpcodes database
v · d · e
Vice City Grand Theft Auto: Vice City
File Formats.adf.col.cfg.dff.dat.gxt.ide.ifp.img/.dir.ipl.raw/.sdt.rep.scm.txd
DocumentationAudioHandlingMap ListingOpcodesScript PathsSavesSound Effects
ToolsCLEOCollision File Editor IIG-ToolsGXT EditorIMG ToolLimit AdjusterKEd (map editor)Sanny BuilderTXD Workshop
TutorialsHow to create a missionHow to create a threadVehicle Mod Installation
MultiplayerGTA:LC MultiplayergtaTournamentMulti Theft AutoState Of Liberty OnlineVice City MultiplayerVice City Online
Useful linksCommunity portalDiscussion forumsMods on GTAGarage.comModding VC Mobile versionOpcodes database
v · d · e
GTA III Grand Theft Auto III
File Formats.col.cfg.dff.dat.gxt.ide.ifp.img.ipl.raw/.sdt.scm.txd
DocumentationAudioHandling.cfgMap ListingOpcodesPathsSaves
ToolsCLEOCollision File Editor IIG-ToolsIMG ToolMap EditorSanny BuilderTXD WorkshopWater Editor
TutorialsHow to create a missionHow to create a threadHow to use Map EditorVehicle Mod Installation
MultiplayerLiberty UnleashedMulti Theft AutoMore...
Useful linksCommunity portalDiscussion forumsMods on GTAGarage.comModding GTA 3 Mobile versionOpcodes database