Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
@lunapaint/tga-codec
Advanced tools
This is a TGA decoder library for JavaScript that runs in both the browser and in Node.js. It is used in Luna Paint (an image editor for VS Code) to work with TGA files.
You can try it out on vscode.dev
by installing the Luna Paint extension and opening a tga file.
detectAmbiguousAlphaChannel
option.The supported way of installing the project is through npm:
npm install @lunapaint/tga-codec
Alternatively, you could add the repo as a git submodule, or download the source from the GitHub releases page.
Basic usage:
import { decodeTga } from '@lunapaint/tga-codec';
import * as fs from 'fs/promises';
async function decode(filepath) {
const data = await fs.readFile(filepath);
const decoded = await decodeTga(data);
console.log('decoded image', decoded.image.data);
// [r, g, b, a, ...]
}
The full API is documented as a TypeScript .d.ts
declaration file. The view the API:
Go to Symbol in Editor
commandWhile writing this codec I became aware that other TGA decoders are inconsistent, don't handle seemingly common cases and the spec is ambiguous. Some examples of these issues:
Here are the details on what this codec supports:
(c << 3) | (c >> 2)
where c
is the channel value.A `color map` is defined and its `bit depth` is 32
OR
(
The `attribute bits per pixel` in the `image descriptor` field is > 0
OR
The `bit depth` field is 32
)
AND
(
There is no `extension area`
OR
The `attributes type` field in the `extension area` is 0, 1 or 2
)
detectAmbiguousAlphaChannel
can be enabled which will detect images with ambiguous alpha and disable alpha is enabling it would result in a fully transparent image. Ambiguoius alpha is defined as when alpha is enabled as above and attribute bits per pixel
is 0.FAQs
Decode tga files in web or node
We found that @lunapaint/tga-codec demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.