Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Image to TXT converter

Simple library to convert an image to a text file. Some techniques were borrowed from this article.

This was created for p2r3's convert but can be used independently.

Usage

Application

To run the application, do:

deno run --allow-read src/app.ts <image name>

The text version is outputted to STDOUT.

Library

This repository can be included as a git submodule or by other means, then:

import { imageToText } from "/path/to/image-to-txt/convert.ts";
const str = imageToText({
    width() { ... },
    height() { ... },
    getPixel(x: number, y: number) { ... }
})
// str contains the returned text

Generating a font

A font atlas must be placed at ./assets/atlas.png; this should be an image containing all ASCII characters horizontally. This repository contains one by default. Then, you should run deno run src/generate.ts; this will create src/generated.ts which will contain the font data necessary for creating an image.

Contributing

Contributions welcome. However, do not contribute on the GitHub repository - any PRs or issues there will be closed.

Please use the mailing list on the sourcehut repository to send patches and bug reports.

TODO

Needs to be optimized; performance is currently very bad.

Could implement better contrast as suggested by the linked blogpost.

Releases

Packages

Contributors

Languages