Remove autoOrientJPEG and consolidate downscaling logic
This commit is contained in:
parent
3eed6cb350
commit
09b5e6ef50
10 changed files with 105 additions and 144 deletions
|
@ -108,12 +108,17 @@ async function getCanvasBlobAsJPEG(
|
|||
return canvasToBlob(canvas, IMAGE_JPEG, quality);
|
||||
}
|
||||
|
||||
export async function scaleImageToLevel(
|
||||
fileOrBlobOrURL: File | Blob | string,
|
||||
contentType: MIMEType,
|
||||
size: number,
|
||||
sendAsHighQuality?: boolean
|
||||
): Promise<{
|
||||
export async function scaleImageToLevel({
|
||||
fileOrBlobOrURL,
|
||||
contentType,
|
||||
size,
|
||||
highQuality,
|
||||
}: {
|
||||
fileOrBlobOrURL: File | Blob | string;
|
||||
contentType: MIMEType;
|
||||
size: number;
|
||||
highQuality: boolean | null;
|
||||
}): Promise<{
|
||||
blob: Blob;
|
||||
contentType: MIMEType;
|
||||
}> {
|
||||
|
@ -134,16 +139,13 @@ export async function scaleImageToLevel(
|
|||
throw error;
|
||||
}
|
||||
|
||||
const level = sendAsHighQuality
|
||||
? MediaQualityLevels.Three
|
||||
: getMediaQualityLevel();
|
||||
const level = highQuality ? MediaQualityLevels.Three : getMediaQualityLevel();
|
||||
const {
|
||||
maxDimensions,
|
||||
quality,
|
||||
size: targetSize,
|
||||
thresholdSize,
|
||||
} = MEDIA_QUALITY_LEVEL_DATA.get(level) || DEFAULT_LEVEL_DATA;
|
||||
|
||||
if (size <= thresholdSize) {
|
||||
// Always encode through canvas as a temporary fix for a library bug
|
||||
const blob: Blob = await canvasToBlob(data.image, contentType);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue