fix: prevent image uploader converting every image to jpeg (#1262)
parent
db7711869f
commit
23127318dc
|
@ -125,9 +125,9 @@ export default function ImageUploader({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
<div className="flex flex-col items-center justify-center p-8 mt-6 cropper bg-gray-50">
|
<div className="flex flex-col items-center justify-center p-8 mt-6 cropper">
|
||||||
{!result && (
|
{!result && (
|
||||||
<div className="flex items-center justify-start w-20 h-20 bg-gray-500 rounded-full max-h-20">
|
<div className="flex items-center justify-start w-20 h-20 bg-gray-50 rounded-full max-h-20">
|
||||||
{!imageSrc && (
|
{!imageSrc && (
|
||||||
<p className="w-full text-sm text-center text-white sm:text-xs">
|
<p className="w-full text-sm text-center text-white sm:text-xs">
|
||||||
{t("no_target", { target })}
|
{t("no_target", { target })}
|
||||||
|
|
|
@ -45,7 +45,7 @@ export async function getCroppedImg(imageSrc: string, pixelCrop: Area): Promise<
|
||||||
// on very low ratios, the quality of the resize becomes awful. For this reason the resizeRatio is limited to 0.75
|
// on very low ratios, the quality of the resize becomes awful. For this reason the resizeRatio is limited to 0.75
|
||||||
if (resizeRatio <= 0.75) {
|
if (resizeRatio <= 0.75) {
|
||||||
// With a smaller image, thus improved ratio. Keep doing this until the resizeRatio > 0.75.
|
// With a smaller image, thus improved ratio. Keep doing this until the resizeRatio > 0.75.
|
||||||
return getCroppedImg(canvas.toDataURL("image/jpeg"), {
|
return getCroppedImg(canvas.toDataURL("image/png"), {
|
||||||
width: canvas.width,
|
width: canvas.width,
|
||||||
height: canvas.height,
|
height: canvas.height,
|
||||||
x: 0,
|
x: 0,
|
||||||
|
@ -53,5 +53,5 @@ export async function getCroppedImg(imageSrc: string, pixelCrop: Area): Promise<
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return canvas.toDataURL("image/jpeg");
|
return canvas.toDataURL("image/png");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue