Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/vs/platform/browserView/common/browserView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export interface IBrowserViewBounds {
}

export interface IBrowserViewCaptureScreenshotOptions {
/** Image format. Defaults to `'jpeg'`. */
format?: 'jpeg' | 'png';
/** Image quality (0-100). Only applies when {@link format} is `'jpeg'`. Defaults to 80. */
quality?: number;
screenRect?: { x: number; y: number; width: number; height: number };
pageRect?: { x: number; y: number; width: number; height: number };
Expand Down
2 changes: 1 addition & 1 deletion src/vs/platform/browserView/electron-main/browserView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ export class BrowserView extends Disposable {
const image = await this._view.webContents.capturePage(options?.screenRect, {
stayHidden: true
});
const buffer = image.toJPEG(quality);
const buffer = options?.format === 'png' ? image.toPNG() : image.toJPEG(quality);
const screenshot = VSBuffer.wrap(buffer);
// Only update _lastScreenshot if capturing the full view
if (!options?.screenRect) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ export class BrowserEditorChatIntegration extends BrowserEditorContribution {
const attachImages = this.configurationService.getValue<boolean>('chat.sendElementsToChat.attachImages');
if (attachImages) {
const screenshotBuffer = await model.captureScreenshot({
quality: 90,
format: 'png',
pageRect: bounds
});

Expand Down
Loading