mirror of
https://github.com/CaramelFur/Picsur.git
synced 2025-11-07 12:35:39 +01:00
add qoi upload support
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
SupportedMimeCategory
|
||||
} from 'picsur-shared/dist/dto/mimes.dto';
|
||||
import { AsyncFailable, Fail } from 'picsur-shared/dist/types';
|
||||
import { QOIColorSpace, QOIencode } from 'qoi-img';
|
||||
import { QOIColorSpace, QOIdecode, QOIencode } from 'qoi-img';
|
||||
import sharp from 'sharp';
|
||||
import { UsrPreferenceService } from '../../collections/preferencesdb/usrpreferencedb.service';
|
||||
|
||||
@@ -50,10 +50,12 @@ export class ImageProcessorService {
|
||||
sharpImage = this.icoSharp(image);
|
||||
} else if (mime.mime === ImageMime.BMP) {
|
||||
sharpImage = this.bmpSharp(image);
|
||||
} else if (mime.mime === ImageMime.QOI) {
|
||||
sharpImage = this.qoiSharp(image);
|
||||
} else {
|
||||
sharpImage = sharp(image);
|
||||
}
|
||||
mime.mime = ImageMime.PNG;
|
||||
mime.mime = ImageMime.QOI;
|
||||
|
||||
sharpImage = sharpImage.toColorspace('srgb');
|
||||
|
||||
@@ -111,4 +113,16 @@ export class ImageProcessorService {
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
private qoiSharp(image: Buffer) {
|
||||
const result = QOIdecode(image);
|
||||
|
||||
return sharp(result.pixels, {
|
||||
raw: {
|
||||
width: result.width,
|
||||
height: result.height,
|
||||
channels: result.channels,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user