chenbhao Claude Big Pickle commited on
Commit
050f245
·
1 Parent(s): 67fd3a5

fix(ImageShowTool): read local file to buffer before Jimp.read

Browse files

Jimp v1.x has inconsistent path resolution in some runtimes (Bun, ESM).
Read file to Buffer via fs.readFileSync first, then pass to Jimp.read()
to ensure reliable local file loading.

Co-Authored-By: Claude Big Pickle <noreply@anthropic.com>

src/tools/ImageShowTool/ImageShowTool.ts CHANGED
@@ -1,4 +1,5 @@
1
  import { execFileSync } from 'child_process'
 
2
  import { z } from 'zod/v4'
3
  import { Jimp } from "jimp";
4
  import { buildTool, type ToolDef } from '../../Tool.js'
@@ -51,7 +52,12 @@ export async function loadImage(path: string) {
51
  if (isUrl(path)) {
52
  return loadImageFromUrl(path);
53
  } else {
54
- return Jimp.read(path);
 
 
 
 
 
55
  }
56
  }
57
 
 
1
  import { execFileSync } from 'child_process'
2
+ import fs from 'node:fs'
3
  import { z } from 'zod/v4'
4
  import { Jimp } from "jimp";
5
  import { buildTool, type ToolDef } from '../../Tool.js'
 
52
  if (isUrl(path)) {
53
  return loadImageFromUrl(path);
54
  } else {
55
+ // Read file to Buffer first, then pass to Jimp.read().
56
+ // Jimp v1.x has inconsistent path resolution in some runtimes
57
+ // (Bun, ESM contexts), so this avoids relying on Jimp's internal
58
+ // file detection by feeding the raw buffer directly.
59
+ const buffer = fs.readFileSync(path);
60
+ return Jimp.read(buffer);
61
  }
62
  }
63