Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/platform/image/vscode-node/imageServiceImpl.ts
13401 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import * as vscode from 'vscode';
7
import { ICAPIClientService } from '../../endpoint/common/capiClient';
8
import { ILogService } from '../../log/common/logService';
9
import { ImageServiceImpl } from '../node/imageServiceImpl';
10
11
export class VSCodeImageServiceImpl extends ImageServiceImpl {
12
constructor(
13
@ICAPIClientService capiClient: ICAPIClientService,
14
@ILogService private readonly logService: ILogService,
15
) {
16
super(capiClient);
17
}
18
19
override async resizeImage(data: Uint8Array, mimeType: string): Promise<{ data: Uint8Array; mimeType: string }> {
20
try {
21
const result = await vscode.commands.executeCommand('_chat.resizeImage', data, mimeType);
22
if (result instanceof Uint8Array) {
23
return { data: result, mimeType };
24
}
25
} catch (e) {
26
this.logService.trace(`ImageService: failed to resize image, using original: ${e}`);
27
}
28
return { data, mimeType };
29
}
30
}
31
32