Skip to content

Commit

Permalink
Fix(frontend): Fix resolution of cropped image (misskey-dev#11489)
Browse files Browse the repository at this point in the history
  • Loading branch information
tai-cha committed Feb 4, 2024
1 parent 66714d9 commit cd47f03
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/frontend/src/components/MkCropperDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ const loading = ref(true);
const ok = async () => {
const promise = new Promise<Misskey.entities.DriveFile>(async (res) => {
const croppedCanvas = await cropper?.getCropperSelection()?.$toCanvas();
const croppedImage = await cropper?.getCropperImage();
const croppedSection = await cropper?.getCropperSelection();
// 拡大率を計算し、(ほぼ)元の大きさに戻す
const zoomedRate = croppedImage.getBoundingClientRect().width / croppedImage.clientWidth;
const widthToRender = croppedSection.getBoundingClientRect().width / zoomedRate;
const croppedCanvas = await croppedSection?.$toCanvas({ width: widthToRender });
croppedCanvas?.toBlob(blob => {
if (!blob) return;
const formData = new FormData();
Expand Down

0 comments on commit cd47f03

Please sign in to comment.