Skip to content

Commit 9e1ba4a

Browse files
committed
feat: use the original format of images
1 parent 6cd4ad9 commit 9e1ba4a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

packages/core/src/image.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ export class Image {
113113
| Jp2Options
114114
| TiffOptions,
115115
) {
116-
return this.sharp.toFormat(format, options);
116+
this.sharp.toFormat(format, options);
117+
return this;
118+
}
119+
120+
toBuffer() {
121+
return this.sharp.toBuffer();
117122
}
118123

119124
clone() {

packages/core/src/loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function process(this: Rspack.LoaderContext, content: Buffer) {
2626
logger.debug(`Creating thumbnail: ${thumbnail.width}x${thumbnail.height}`);
2727
image.resize(thumbnail);
2828

29-
const buf = await image.format('jpeg').toBuffer();
29+
const buf = await image.toBuffer();
3030
thumbnail.url = `data:image/jpeg;base64,${buf.toString('base64')}`;
3131
logger.debug(`Created thumbnail: ${thumbnail.url}`);
3232

0 commit comments

Comments
 (0)