Skip to content

Commit 0fa8a79

Browse files
remote-swe-userremote-swe-app[bot]
and
remote-swe-app[bot]
authored
Save images in JPEG format locally for better CLI compatibility (#17)
## Description This PR fixes issue #16 by changing the image format from webp to JPEG when saving images locally. ### Changes - Modified the `saveImageToLocalFs` function to convert webp images to JPEG format before saving - WebP format is still used in the `postProcessMessageContent` function for efficiency - Changed file extension from 'webp' to 'jpeg' This change improves compatibility with various CLI tools that may not handle webp files as easily as JPEG. closes #16 Co-authored-by: remote-swe-app[bot] <123456+remote-swe-app[bot]@users.noreply.github.com>
1 parent 50cf7e3 commit 0fa8a79

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

worker/src/agent/common/messages.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,16 @@ const ensureImagesDirectory = () => {
215215
const saveImageToLocalFs = async (imageBuffer: Buffer): Promise<string> => {
216216
const imagesDir = ensureImagesDirectory();
217217

218-
// Since we're converting to webp above, we know the extension
219-
const extension = 'webp';
218+
// Convert webp to jpeg for better compatibility with CLI tools
219+
const jpegBuffer = await sharp(imageBuffer).jpeg({ quality: 85 }).toBuffer();
220+
const extension = 'jpeg';
220221

221222
// Create path with sequence number
222223
const fileName = `image${imageSeqNo}.${extension}`;
223224
const filePath = path.join(imagesDir, fileName);
224225

225226
// Write image to file
226-
writeFileSync(filePath, imageBuffer);
227+
writeFileSync(filePath, jpegBuffer);
227228

228229
// Increment sequence number for next image
229230
imageSeqNo++;

0 commit comments

Comments
 (0)