|
1 | 1 | /** |
2 | 2 | * Terminal image rendering utilities |
3 | 3 | * Supports iTerm2 inline images protocol and Kitty graphics protocol |
4 | | - * Falls back to ANSI block characters for unsupported terminals |
5 | 4 | */ |
6 | 5 |
|
7 | | -import terminalImage from 'terminal-image' |
8 | | - |
9 | 6 | import { logger } from './logger' |
10 | 7 |
|
11 | 8 | export type TerminalImageProtocol = 'iterm2' | 'kitty' | 'sixel' | 'none' |
@@ -226,66 +223,3 @@ export function getImageSupportDescription(): string { |
226 | 223 | return 'No inline image support' |
227 | 224 | } |
228 | 225 | } |
229 | | - |
230 | | -/** |
231 | | - * Render an image using ANSI block characters (Unicode half-blocks) |
232 | | - * This works in any terminal that supports 24-bit color |
233 | | - * @param imageBuffer - Buffer containing image data |
234 | | - * @param options - Display options |
235 | | - * @returns Promise resolving to the ANSI escape sequence string |
236 | | - */ |
237 | | -export async function renderAnsiBlockImage( |
238 | | - imageBuffer: Buffer, |
239 | | - options: { |
240 | | - width?: number |
241 | | - height?: number |
242 | | - } = {}, |
243 | | -): Promise<string> { |
244 | | - const { width = 20, height = 10 } = options |
245 | | - |
246 | | - try { |
247 | | - const result = await terminalImage.buffer(imageBuffer, { |
248 | | - width, |
249 | | - height, |
250 | | - preserveAspectRatio: true, |
251 | | - }) |
252 | | - return result |
253 | | - } catch (error) { |
254 | | - logger.debug( |
255 | | - { error: error instanceof Error ? error.message : String(error) }, |
256 | | - 'Failed to render ANSI block image from buffer', |
257 | | - ) |
258 | | - return '' |
259 | | - } |
260 | | -} |
261 | | - |
262 | | -/** |
263 | | - * Render an image from a file path using ANSI block characters |
264 | | - * @param filePath - Path to the image file |
265 | | - * @param options - Display options |
266 | | - * @returns Promise resolving to the ANSI escape sequence string |
267 | | - */ |
268 | | -export async function renderAnsiBlockImageFromFile( |
269 | | - filePath: string, |
270 | | - options: { |
271 | | - width?: number |
272 | | - height?: number |
273 | | - } = {}, |
274 | | -): Promise<string> { |
275 | | - const { width = 20, height = 10 } = options |
276 | | - |
277 | | - try { |
278 | | - const result = await terminalImage.file(filePath, { |
279 | | - width, |
280 | | - height, |
281 | | - preserveAspectRatio: true, |
282 | | - }) |
283 | | - return result |
284 | | - } catch (error) { |
285 | | - logger.debug( |
286 | | - { filePath, error: error instanceof Error ? error.message : String(error) }, |
287 | | - 'Failed to render ANSI block image from file', |
288 | | - ) |
289 | | - return '' |
290 | | - } |
291 | | -} |
0 commit comments