# ts-transform-img

> Allow `import * as img from 'foo.png'` in TS

Latest version **0.4.2** (published 2019-06-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install ts-transform-img
pnpm add ts-transform-img
yarn add ts-transform-img
bun add ts-transform-img
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.2 |
| Published | 2019-06-05 |
| First published | 2017-04-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 12.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 24 |
| Author | Long Ho |
| Maintainers | longlho |
| Keywords | typescript, transform, png |

## Links

- npm: https://www.npmjs.com/package/ts-transform-img
- Repository: https://github.com/longlho/ts-transform-img
- Homepage: https://github.com/longlho/ts-transform-img#readme
- Issues: https://github.com/longlho/ts-transform-img/issues
- npm.io page: https://npm.io/package/ts-transform-img

## Dependencies (3)

- [typescript](https://npm.io/package/typescript.md) ^3.2
- [loader-utils](https://npm.io/package/loader-utils.md) ^1.2.3
- [@types/loader-utils](https://npm.io/package/@types/loader-utils.md) ^1.1.3

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.4.2 (latest) — 2019-06-05
- 0.4.1 — 2019-06-05
- 0.4.0 — 2019-04-29
- 0.3.3 — 2019-04-12
- 0.3.2 — 2018-12-10
- 0.3.1 — 2018-12-10
- 0.3.0 — 2018-12-07
- 0.2.3 — 2018-11-21
- 0.2.1 — 2017-11-13
- 0.2.0 — 2017-09-17
- 0.1.2 — 2017-04-29
- 0.1.1 — 2017-04-29
- 0.1.0 — 2017-04-29

## README

# ts-transform-img

![build status](https://travis-ci.org/longlho/ts-transform-img.svg?branch=master)
[![Greenkeeper badge](https://badges.greenkeeper.io/longlho/ts-transform-img.svg)](https://greenkeeper.io/)

This is a TypeScript AST Transformer that allows you to write `import * as img from 'foo.png'`. Depending on file size, the img with be base64-inlined in the source or aggregated via `onImgExtracted`.

## Usage
First of all, you need some level of familiarity with the [TypeScript Compiler API](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API).

`compile.ts` & tests should have examples of how this works. The available options are:

### `threshold?: number`
Threshold of img size that will be inlined, default to 10K

### `interpolateName?: InterpolateNameFn | string`
Function to generate ID for the img asset

### `onImgExtracted(id: string, filePath: string): void`
Function that gets triggered every time we found an asset

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