@@ -2,7 +2,7 @@ import process from 'node:process';
22import fs from 'node:fs' ;
33import fsPromises from 'node:fs/promises' ;
44import chalk from 'chalk' ;
5- import Jimp from 'jimp' ;
5+ import { Jimp , intToRGBA } from 'jimp' ;
66import termImg from 'term-img' ;
77import renderGif from 'render-gif' ;
88import logUpdate from 'log-update' ;
@@ -71,18 +71,18 @@ function calculateWidthHeight(imageWidth, imageHeight, inputWidth, inputHeight,
7171}
7272
7373async function render ( buffer , { width : inputWidth , height : inputHeight , preserveAspectRatio} ) {
74- const image = await Jimp . read ( Buffer . from ( buffer ) ) ;
74+ const image = await Jimp . fromBuffer ( buffer ) ;
7575 const { bitmap} = image ;
7676
7777 const { width, height} = calculateWidthHeight ( bitmap . width , bitmap . height , inputWidth , inputHeight , preserveAspectRatio ) ;
7878
79- image . resize ( width , height ) ;
79+ image . resize ( { w : width , h : height } ) ;
8080
8181 let result = '' ;
82- for ( let y = 0 ; y < image . bitmap . height - 1 ; y += 2 ) {
83- for ( let x = 0 ; x < image . bitmap . width ; x ++ ) {
84- const { r, g, b, a} = Jimp . intToRGBA ( image . getPixelColor ( x , y ) ) ;
85- const { r : r2 , g : g2 , b : b2 } = Jimp . intToRGBA ( image . getPixelColor ( x , y + 1 ) ) ;
82+ for ( let y = 0 ; y < bitmap . height - 1 ; y += 2 ) {
83+ for ( let x = 0 ; x < bitmap . width ; x ++ ) {
84+ const { r, g, b, a} = intToRGBA ( image . getPixelColor ( x , y ) ) ;
85+ const { r : r2 , g : g2 , b : b2 } = intToRGBA ( image . getPixelColor ( x , y + 1 ) ) ;
8686 result += a === 0 ? chalk . reset ( ' ' ) : chalk . bgRgb ( r , g , b ) . rgb ( r2 , g2 , b2 ) ( PIXEL ) ;
8787 }
8888
0 commit comments