Skip to content

Commit

Permalink
init: convert repo to a workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackAsLight committed Nov 16, 2024
1 parent 6ec8f04 commit 568dc2d
Show file tree
Hide file tree
Showing 17 changed files with 71 additions and 83 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@ name: Run Tests
on:
push:
branches:
- main
- "*"
pull_request:
branches:
- main
workflow_dispatch:
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- uses: denoland/setup-deno@v2
- run: deno test -R='./' -W='./' --parallel --doc --trace-leaks
- run: deno test -R='.output/' -W='.output/' --parallel --doc --trace-leaks
lint:
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
coverage/
.coverage/
.output/
51 changes: 21 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
# qoi
# Img

This is a TypeScript implementation of the QOI image format. The module offers
both sync and streaming versions to encode and decode to and from the QOI image
format. The raw pixel format/ the decoded format is a repeating sequence of
`[ r, g, b, a ]` in a `Uint8Array`, `Uint8ClampedArray`, or a
`ReadableStream<Uint8Array>`.
Img is a repo containing implemenetations, made from scratch, of various image
formats offering the ability to encode and decode between them, and integrate
smoothly with various Web APIs like the Canvas. Where possible, we offer both
sync and streaming encoders/decoders.

This implementationis based off the
[QOI Specification](https://qoiformat.org/qoi-specification.pdf). You can find
about more about QOI at their website: https://qoiformat.org/.
## Missing a format?

## Example
If this repo is missing a format you'd like to work with, simply create an issue
suggesting the format, along with a link to the standard, specifcation or some
document that is essentally the source of truth for that format. Do that and it
might get an implementation here.

```ts
import { encodeQOI } from "@img/qoi";
## Formats

const rawData = await new Response(ReadableStream.from(async function* () {
for (let r = 0; r < 256; ++r) {
for (let c = 0; c < 256; ++c) {
yield Uint8Array.from([255 - r, c, r, 255]);
}
}
}())).bytes();

await Deno.writeFile(
"image.qoi",
encodeQOI(rawData, {
width: 256,
height: 256,
channels: "rgb",
colorspace: 0,
}),
);
```
| Package | Latest Version | Spec |
| ------------------------------------- | -------------------------------------- | ------------------------------------------------------------ |
| [@img/apng](https://jsr.io/@img/apng) | Not Implemented Yet | https://wiki.mozilla.org/APNG_Specification |
| [@img/avif](https://jsr.io/@img/avif) | Not Implemented Yet | https://aomediacodec.github.io/av1-avif/v1.1.0.html |
| [@img/gif](https://jsr.io/@img/gif) | Not Implemented Yet | https://www.w3.org/Graphics/GIF/spec-gif89a.txt |
| [@img/jpeg](https://jsr.io/@img/jpeg) | Not Implemented Yet | https://www.w3.org/Graphics/JPEG/jfif3.pdf |
| [@img/png](https://jsr.io/@img/png) | Not Implemented Yet | https://www.w3.org/TR/2003/REC-PNG-20031110/ |
| [@img/qoi](https://jsr.io/@img/qoi) | ![JSR](https://jsr.io/badges/@img/qoi) | https://qoiformat.org/qoi-specification.pdf |
| [@img/avg](https://jsr.io/@img/svg) | Not Implemented Yet | https://www.w3.org/TR/SVG2/ |
| [@img/webp](https://jsr.io/@img/webp) | Not Implemented Yet | https://developers.google.com/speed/webp/docs/riff_container |
37 changes: 10 additions & 27 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,20 @@
{
"name": "@img/qoi",
"version": "0.1.3",
"publish": {
"exclude": ["**/.*"]
},
"workspace": ["qoi"],
"imports": {
"@std/assert": "jsr:@std/assert@^1.0.6",
"@std/bytes": "jsr:@std/bytes@^1.0.2",
"@std/streams": "jsr:@std/streams@^1.0.7"
},
"exports": {
".": "./src/mod.ts",
"./decode": "./src/decode.ts",
"./decoder-stream": "./src/decoder_stream.ts",
"./encode": "./src/encode.ts",
"./encoder-stream": "./src/encoder_stream.ts"
"@std/assert": "jsr:@std/assert@1",
"@std/bytes": "jsr:@std/bytes@1",
"@std/streams": "jsr:@std/streams@1"
},
"exclude": ["**/.*"],
"tasks": {
"coverage": "deno coverage --html coverage/",
"coverage:mac": "deno task coverage && open coverage/html/index.html",
"coverage:lin": "deno task coverage && xdg-open coverage/html/index.html",
"coverage:win": "deno task coverage && start coverage/html/index.html",
"test": "deno test -R='./' -W='./' --parallel --doc --trace-leaks --coverage --clean && rm image.qoi",
"cov": "deno coverage --html .coverage/",
"cov:mac": "deno task cov && open .coverage/html/index.html",
"cov:lin": "deno task cov && xdg-open .coverage/html/index.html",
"cov:win": "deno task cov && start .coverage/html/index.html",
"test": "deno test -R='.output/' -W='.output/' --parallel --doc --trace-leaks --coverage='.coverage/' --clean",
"ok": "deno fmt && deno lint && deno task test"
},
"fmt": {
"exclude": ["coverage/", "**/.*"]
},
"lint": {
"exclude": ["coverage/", "**/.*"],
"rules": {
"tags": ["recommended"],
"include": [
Expand All @@ -47,8 +33,5 @@
"verbatim-module-syntax"
]
}
},
"test": {
"exclude": ["coverage/", "**/.*"]
}
}
33 changes: 15 additions & 18 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 11 additions & 0 deletions qoi/deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@img/qoi",
"version": "0.1.3",
"exports": {
".": "./mod.ts",
"./decode": "./decode.ts",
"./decoder-stream": "./decoder_stream.ts",
"./encode": "./encode.ts",
"./encoder-stream": "./encoder_stream.ts"
}
}
4 changes: 3 additions & 1 deletion src/encode.ts → qoi/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { QOIOptions } from "./types.ts";
* ```ts
* import { encodeQOI } from "@img/qoi";
*
* await Deno.mkdir(".output/", { recursive: true });
*
* const rawData = await new Response(ReadableStream.from(async function* () {
* for (let r = 0; r < 256; ++r) {
* for (let c = 0; c < 256; ++c) {
Expand All @@ -18,7 +20,7 @@ import type { QOIOptions } from "./types.ts";
* }
* }())).bytes();
*
* await Deno.writeFile("image.qoi", encodeQOI(rawData, {
* await Deno.writeFile(".output/image.qoi", encodeQOI(rawData, {
* width: 256,
* height: 256,
* channels: "rgb",
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion src/encoder_stream.ts → qoi/encoder_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import type { QOIOptions } from "./types.ts";
* ```ts
* import { QOIEncoderStream } from "@img/qoi";
*
* await Deno.mkdir(".output/", { recursive: true });
*
* await ReadableStream
* .from(async function* () {
* for (let r = 0; r < 256; ++r) {
Expand All @@ -26,7 +28,7 @@ import type { QOIOptions } from "./types.ts";
* colorspace: 0,
* }),
* )
* .pipeTo((await Deno.create("image.qoi")).writable);
* .pipeTo((await Deno.create(".output/image.qoi")).writable);
* ```
*
* @module
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion src/mod.ts → qoi/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
* ```ts
* import { encodeQOI } from "@img/qoi";
*
* await Deno.mkdir(".output/", { recursive: true });
*
* const rawData = await new Response(ReadableStream.from(async function* () {
* for (let r = 0; r < 256; ++r) {
* for (let c = 0; c < 256; ++c) {
Expand All @@ -21,7 +23,7 @@
* }
* }())).bytes();
*
* await Deno.writeFile("image.qoi", encodeQOI(rawData, {
* await Deno.writeFile(".output/image.qoi", encodeQOI(rawData, {
* width: 256,
* height: 256,
* channels: "rgb",
Expand Down
File renamed without changes.

0 comments on commit 568dc2d

Please sign in to comment.