Skip to content

AnriTool/RwIMGReader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grand Theft Auto(III, VC, SA) img-archive reader.

npm NPM

Allows you to get data from GTA [III, VC, SA] img archive

Example

GTA SA Features

GTA SA does not have a .dir archive, it is included inside the .img. You can put one buffer in both loadDIR and loadIMG methods

const resource = readFileSync('./assets/gta3.img').buffer;
imgReader.loadDIR(resource);
imgReader.loadIMG(resource);

console example(without browser)

save infernus.txd + infernus.dff

import {ImgReader} from "rw-img-reader";
import {readFileSync, writeFileSync} from 'fs';

const imgReader = new ImgReader();
imgReader.loadDIR(readFileSync('./assets/gta3.dir').buffer);
imgReader.loadIMG(readFileSync('./assets/gta3.img').buffer);

for (const asset of imgReader.getAssetList()) {
	if (asset.name.includes('infernus')) {
		// save file
		writeFileSync('./assets/unpacked/' + asset.name , Buffer.from(imgReader.loadAsset(asset)))
	}
}

Browser example

write all resources in browser console

import {ImgReader} from "rw-img-reader";

async function example() {
	const imgReader = new ImgReader();

	const dirResource = ((await fetch('http://localhost:5173/gta3.dir')).arrayBuffer());
	imgReader.loadDIR(await dirResource);

	const imgResource = (await fetch('http://localhost:5173/gta3.img')).arrayBuffer();
	imgReader.loadIMG(await imgResource);

	console.log(imgReader.getAssetList())
}

example();

using with rw-parser

const dffAsset = imgReader.getAssetByName('infernus.dff');
if (dffAsset) {
	const dffParser = new DffParser(Buffer.from(imgReader.loadAsset(dffAsset)))
	console.log(dffParser.parse());
}

const txdAsset = imgReader.getAssetByName('infernus.txd');
if (txdAsset) {
	const dffParser = new TxdParser(Buffer.from(imgReader.loadAsset(txdAsset)))
	console.log(dffParser.parse());
}

About

Allows you to get data from GTA [III, VC, SA] img archive

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published