mirror of
https://github.com/microsoft/vscode.git
synced 2026-06-30 03:16:17 +01:00
cc86f3c7a3
* Add dedicated view image tool (Written by Copilot) * Remove stale read file test import (Written by Copilot) * Add image extension coverage test (Written by Copilot) * Update test snapshots
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { URI } from '../../../util/vs/base/common/uri';
|
|
import { ChatImageMimeType } from '../../conversation/common/languageModelChatMessageHelpers';
|
|
|
|
/** Maximum image file size in bytes (20 MB) */
|
|
export const MAX_IMAGE_FILE_SIZE = 20 * 1024 * 1024;
|
|
|
|
const imageExtensionToMimeType: Record<string, ChatImageMimeType> = {
|
|
'.png': ChatImageMimeType.PNG,
|
|
'.jpg': ChatImageMimeType.JPEG,
|
|
'.jpeg': ChatImageMimeType.JPEG,
|
|
'.gif': ChatImageMimeType.GIF,
|
|
'.webp': ChatImageMimeType.WEBP,
|
|
};
|
|
|
|
export function getImageMimeType(uri: URI): ChatImageMimeType | undefined {
|
|
const path = uri.path.toLowerCase();
|
|
for (const [ext, mime] of Object.entries(imageExtensionToMimeType)) {
|
|
if (path.endsWith(ext)) {
|
|
return mime;
|
|
}
|
|
}
|
|
|
|
return undefined;
|
|
}
|