Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
ascii-pixels
Advanced tools
Convert raw image data to ascii art!
npm install ascii-pixels
input raw image data, and optionally set contrast or invert colors
var options = {
contrast: 128, // range -255 to +255
invert: true // invert brightness
}
var ascii = asciiPixels(imageData, options)
The raw image data has the following format:
var imageData = {
data: frameData,
width: width,
height: height
}
You may optionally provide the pixel format: imageData.format = 'RGB24'
, by default it is RGB32
.
Any format is supported as long as you can get the raw image data. Here are a few examples:
var fs = require('fs')
var jpeg = require('jpeg-js')
var asciiPixels = require('ascii-pixels')
var buffer = fs.readFileSync('image.jpg')
var imageData = jpeg.decode(buffer)
var ascii = asciiPixels(imageData)
console.log(ascii)
var asciiPixels = require('ascii-pixels')
var img = new Image()
img.onload = function () {
var canvas = document.createElement('canvas')
canvas.width = img.width
canvas.height = img.height
var context = canvas.getContext('2d')
context.drawImage(img, 0, 0, img.width, img.height)
var imageData = context.getImageData(0, 0, canvas.width, canvas.height)
var ascii = asciiPixels(imageData)
console.log(ascii)
}
img.src = './nodejs-logo.png'
var fs = require('fs')
var Canvas = require('canvas')
var asciiPixels = require('ascii-pixels')
var img = new Canvas.Image
img.src = fs.readFileSync('nodejs-logo.png')
var canvas = new Canvas(img.width, img.height)
var context = canvas.getContext('2d')
context.drawImage(img, 0, 0, img.width, img.height)
var imageData = context.getImageData(0, 0, canvas.width, canvas.height)
var ascii = asciiPixels(imageData)
console.log(ascii)
C,
8@@@
0@@@
0@@@
@@ .::. CG 8@@@ G8 ...
t@@@@@@@@1 .:::::::;. @@@@@@@@@@ ,@@@@@@@@; . .
@@@@@ff@@@@@ ::::;;::;::: @@@@@0G@@@@@ @@@@@GG@@@@@ . ..,
@@@@ @@@@ ::::;;:;;;:: 0@@@ 8@@@ 8@@@ ,, @@, . ...
@@@@ @@@@ :::;;;;;;;:: 8@@@t ;@@@@ 8@@@L . ... ,
@@@, :@@@ ,:::;;:::,. i@@@@@@@@@@f ,@@@@@@8 . . ..
,,,: .@@@@; 8@@@ . ,
This project is based on the awesome ascii-camera by Andrei Gheorghe
MIT
FAQs
Convert raw image data to ascii art
The npm package ascii-pixels receives a total of 6 weekly downloads. As such, ascii-pixels popularity was classified as not popular.
We found that ascii-pixels 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.