@ascii-kit/image
- Examples
Multiple types of uses
JS (ES Module)
ts
import { image2ascii } from '@ascii-kit/image'
const res = await fetch(
'https://raw.githubusercontent.com/pigeonposse/backan/main/docs/public/logo.png',
)
const input = await res.arrayBuffer()
const ascii = await image2ascii( input, {
fit : 'width',
width : '100%',
height : '100%',
chars : ' #+@',
} )
console.log( ascii )
Fetch Font data as text
ts
import { image2ascii } from '@ascii-kit/image'
const res = await fetch( 'https://github.com/pigeonposse.png?size=72' )
const input = await res.arrayBuffer()
const value = await image2ascii( input, { chars: ' -.@' } )
console.log( value )
Usage with Vite
ts
import { image2ascii } from '@ascii-kit/image'
import { defineConfig } from 'vite'
const getAsciiImage = async ( name: string ) => {
const res = await fetch( name )
const input = await res.arrayBuffer()
return await image2ascii( input, { chars: ' -.@' } )
}
export default defineConfig( { define : {
PROFILE_ASCII_IMAGE : JSON.stringify( await getAsciiImage( 'https://github.com/angelespejo.png?size=72' ) ),
COLLECTIVE_ASCII_IMAGE : JSON.stringify( await getAsciiImage( 'https://github.com/pigeonposse.png?size=72' ) ),
} } )