MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / resizeShellImageOutput

Function resizeShellImageOutput

source code/tools/BashTool/utils.ts:112–133  ·  view source on GitHub ↗
(
  stdout: string,
  outputFilePath: string | undefined,
  outputFileSize: number | undefined,
)

Source from the content-addressed store, hash-verified

110 * parse as a data URI (caller decides whether to flip isImage).
111 */
112export async function resizeShellImageOutput(
113 stdout: string,
114 outputFilePath: string | undefined,
115 outputFileSize: number | undefined,
116): Promise<string | null> {
117 let source = stdout
118 if (outputFilePath) {
119 const size = outputFileSize ?? (await stat(outputFilePath)).size
120 if (size > MAX_IMAGE_FILE_SIZE) return null
121 source = await readFile(outputFilePath, 'utf8')
122 }
123 const parsed = parseDataUri(source)
124 if (!parsed) return null
125 const buf = Buffer.from(parsed.data, 'base64')
126 const ext = parsed.mediaType.split('/')[1] || 'png'
127 const resized = await maybeResizeAndDownsampleImageBuffer(
128 buf,
129 buf.length,
130 ext,
131 )
132 return `data:image/${resized.mediaType};base64,${resized.buffer.toString('base64')}`
133}
134
135export function formatOutput(content: string): {
136 totalLines: number

Callers 2

callFunction · 0.85
callFunction · 0.85

Calls 5

statFunction · 0.85
readFileFunction · 0.85
parseDataUriFunction · 0.85
toStringMethod · 0.65

Tested by

no test coverage detected