-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathimageToolUtils.ts
More file actions
29 lines (24 loc) · 1.08 KB
/
imageToolUtils.ts
File metadata and controls
29 lines (24 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*---------------------------------------------------------------------------------------------
* 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;
}