# tga-js

> A javascript tga loader from browser and node.js

Latest version **1.1.1** (published 2020-10-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install tga-js
pnpm add tga-js
yarn add tga-js
bun add tga-js
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2020-10-01 |
| First published | 2019-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 17.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 48 |
| Author | Vincent Thibault |
| Maintainers | vthibault |
| Keywords | tga, tga.js, tga-js, tga-parser, tga-loader, image, loader |

## Links

- npm: https://www.npmjs.com/package/tga-js
- Repository: https://github.com/vthibault/tga.js
- Homepage: https://github.com/vthibault/tga.js#readme
- Issues: https://github.com/vthibault/tga.js/issues
- npm.io page: https://npm.io/package/tga-js

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2020-10-01
- 1.1.0 — 2019-02-17
- 1.0.0 — 2019-02-17

## README

# tga-js

![Browser](https://img.shields.io/badge/env-browser-blue.svg)
![](https://img.shields.io/david/vthibault/tga.js.svg)
![](https://img.shields.io/snyk/vulnerabilities/github/vthibault/tga.js.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)

**tga-js** is a tga file loader written in JavaScript, working in the browser environment. It provides a simple and really fast solution for loading TGA file format.

> Lot of games are using TGA files to store textures.
> So, since browsers try to bring games in the web it can be a good idea to have a TGA loader _(actually a better idea to use another smaller file format)_.

---

## 🔗 Used by :

- [ThreeJS](https://threejs.org/) 3D Engine
- [BabylonJS](https://www.babylonjs.com/) 3D Engine

---

## 🚀 Installation

Install with [yarn](https://yarnpkg.com):

```sh
$ yarn add tga-js
```

Or install using [npm](https://npmjs.org):

```sh
$ npm i tga-js
```

---

## 📖 Usage

#### Loading a remote tga file.

```js
import TgaLoader from 'tga-js';

const tga = new TgaLoader();
tga.open('./assets/resource.tga', () => {
  document.body.appendChild(tga.getCanvas());
});
```

#### Loading a tga from buffer.

```js
import TgaLoader from 'tga-js';

const tga = new TgaLoader();

// Your own function returning a buffer from cache/memory/..
const buffer = getImageBufferFromCache('resource/data');

tga.load(new UInt8Array(buffer));
document.body.appendChild(tga.getCanvas());
```

#### Get data-uri as output

```js
tga.getDataURL('image/png');
```

---
_Source: https://npm.io/package/tga-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
