![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
image-to-ascii-art
Advanced tools
Image-to-ascii-art can convert image to ascii art in browser.
Look at the image below to see the effect.You can download the image and see the detail.
It convert by canvas,so you just can only use it in browser.
Image-to-ascii-art can be installed using npm,or by including it with the script tag.
npm install image-to-ascii-art
And then import it as dependency in your project.
import ImageToAsciiArt from 'image-to-ascii-art'
It's really simple to use it.
const imageToAsciiArt = new ImageToAsciiArt();
imageToAsciiArt.convert('./test.jpg').then(result => {
document.body.innerHTML = result;
});
imageToAsciiArt.destroy();
Here is some important thing to note.You can read Api first before you read it.
(drawWidth * pickDensityHorizontal)/(drawHeight * pickDensityVertical)
is close to (imageNaturalWidth * fontWidth)/(imageNaturalHeight * fontHeight)
.Main class of image-to-ascii-art.
<HTMLCanvasElement>
Optional.The canvas used to generate ascii art.If it isn't passed,a hidden canvas will be append to body automatically.<ConfigInterface>
Optional.Look at Configuration.Do image to ascii art conversion.You can call it multiple times on the same imageToAsciiArt instance.
<string> | <HTMLImageElement>
The image to convert to ascii art.It can be a url of the image or a HTMLImageElement.<Promise<string>>
The generated ascii art string.Reset Configuration.
<ConfigInterface>
Configuration.Clean up resource.Call it when you will not use this imageToAsciiArt instance any more.
Configuration is passed as param to ImageToAsciiArt class or to setConfig method.
Here is default configuration.Every configuration item is Optional.If you don't set,it will be set as default.
{
drawWidth: 1,
drawHeight: 1,
pickDensityHorizontal: 1,
pickDensityVertical: 1,
greyRangeChar: [
{ from: 0, to: 30, char: '#' },
{ from: 31, to: 60, char: '&' },
{ from: 61, to: 120, char: '$' },
{ from: 121, to: 150, char: '*' },
{ from: 151, to: 180, char: 'o' },
{ from: 181, to: 210, char: '!' },
{ from: 211, to: 240, char: ';' },
],
defaultGreyChar: ' ',
}
<number>
the number of pixels drawn on the canvas.It sets bigger,the generated ascii art will be more detailed.
It has two type to set:
<number>
The integer that pick one for every how many pixels from the canvas.It must be an integer greater than 0.It sets bigger,the generated ascii art will be less detailed.
<Array<{from,to,char}>>
The pixel picked from the image will calculate it's grey.This configuration item decide the grey will be convert to what character.
Every item in the list is a range.It has three child.
<number>
Start of the range.It is close interval.<number>
End of the range.It is close interval.<string>
The character to replace the grey in this range.<string>
If a grey value can't match one of the greyRangeChar config,use this character.
FAQs
convert image to ascii art in browser
We found that image-to-ascii-art 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
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.