upload as JPEG
This commit is contained in:
@@ -12,7 +12,7 @@ const mockResizedImage = {
|
|||||||
size: 100,
|
size: 100,
|
||||||
width: 100,
|
width: 100,
|
||||||
height: 100,
|
height: 100,
|
||||||
mime: 'image/webp',
|
mime: 'image/jpeg',
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('downloadAndResize', () => {
|
describe('downloadAndResize', () => {
|
||||||
@@ -63,7 +63,7 @@ describe('downloadAndResize', () => {
|
|||||||
expect(manipulateAsync).toHaveBeenCalledWith(
|
expect(manipulateAsync).toHaveBeenCalledWith(
|
||||||
expect.any(String),
|
expect.any(String),
|
||||||
[{resize: {height: opts.height, width: opts.width}}],
|
[{resize: {height: opts.height, width: opts.width}}],
|
||||||
{format: SaveFormat.WEBP, compress: 1.0},
|
{format: SaveFormat.JPEG, compress: 1.0},
|
||||||
)
|
)
|
||||||
expect(deleteAsync).toHaveBeenCalledWith(expect.any(String), {
|
expect(deleteAsync).toHaveBeenCalledWith(expect.any(String), {
|
||||||
idempotent: true,
|
idempotent: true,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export async function compressIfNeeded(
|
|||||||
})
|
})
|
||||||
const finalImageMovedPath = await moveToPermanentPath(
|
const finalImageMovedPath = await moveToPermanentPath(
|
||||||
resizedImage.path,
|
resizedImage.path,
|
||||||
'.webp',
|
'.jpg',
|
||||||
)
|
)
|
||||||
const finalImg = {
|
const finalImg = {
|
||||||
...resizedImage,
|
...resizedImage,
|
||||||
@@ -216,7 +216,7 @@ async function doResize(
|
|||||||
localUri,
|
localUri,
|
||||||
[{resize: newDimensions}],
|
[{resize: newDimensions}],
|
||||||
{
|
{
|
||||||
format: SaveFormat.WEBP,
|
format: SaveFormat.JPEG,
|
||||||
compress: qualityPercentage / 100,
|
compress: qualityPercentage / 100,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -234,7 +234,7 @@ async function doResize(
|
|||||||
minQualityPercentage = qualityPercentage
|
minQualityPercentage = qualityPercentage
|
||||||
newDataUri = {
|
newDataUri = {
|
||||||
path: normalizePath(resizeRes.uri),
|
path: normalizePath(resizeRes.uri),
|
||||||
mime: 'image/webp',
|
mime: 'image/jpeg',
|
||||||
size: fileInfo.size,
|
size: fileInfo.size,
|
||||||
width: resizeRes.width,
|
width: resizeRes.width,
|
||||||
height: resizeRes.height,
|
height: resizeRes.height,
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ async function doResize(
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
path: newDataUri,
|
path: newDataUri,
|
||||||
mime: 'image/webp',
|
mime: 'image/jpeg',
|
||||||
size: getDataUriSize(newDataUri),
|
size: getDataUriSize(newDataUri),
|
||||||
width: opts.width,
|
width: opts.width,
|
||||||
height: opts.height,
|
height: opts.height,
|
||||||
@@ -146,7 +146,7 @@ function createResizedImage(
|
|||||||
canvas.height = h
|
canvas.height = h
|
||||||
|
|
||||||
ctx.drawImage(img, 0, 0, w, h)
|
ctx.drawImage(img, 0, 0, w, h)
|
||||||
resolve(canvas.toDataURL('image/webp', quality))
|
resolve(canvas.toDataURL('image/jpeg', quality))
|
||||||
})
|
})
|
||||||
img.addEventListener('error', ev => {
|
img.addEventListener('error', ev => {
|
||||||
reject(ev.error)
|
reject(ev.error)
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ export async function compressImage(img: ComposerImage): Promise<PickerImage> {
|
|||||||
[{resize: {width: w, height: h}}],
|
[{resize: {width: w, height: h}}],
|
||||||
{
|
{
|
||||||
compress: qualityPercentage / 100,
|
compress: qualityPercentage / 100,
|
||||||
format: SaveFormat.WEBP,
|
format: SaveFormat.JPEG,
|
||||||
base64: true,
|
base64: true,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -232,7 +232,7 @@ export async function compressImage(img: ComposerImage): Promise<PickerImage> {
|
|||||||
path: await moveIfNecessary(res.uri),
|
path: await moveIfNecessary(res.uri),
|
||||||
width: res.width,
|
width: res.width,
|
||||||
height: res.height,
|
height: res.height,
|
||||||
mime: 'image/webp',
|
mime: 'image/jpeg',
|
||||||
size,
|
size,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user