Skip to content

Commit

Permalink
🐛 fix: 修正下载的 png 图片渲染问题
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Jun 6, 2021
1 parent 386fd29 commit 5b4779b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/image-gallery/src/utils/png.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,17 @@ export const copyPngFromSvg = async (url: string) => {
*/
export const downloadPng = async (url: string, title: string) => {
const res = await fetch(url);
const size = svgSize(await res.clone().text());
const svgBlob = await res.blob();
const svgUrl = URL.createObjectURL(svgBlob);

const image = new Image();
const image = new Image(size.width * SCALE, size.height * SCALE);
image.src = svgUrl;

image.onload = () => {
const a = document.createElement('a');
a.download = `${title}.png`;
a.href = getImageBase64(image, SCALE);
a.href = getImageBase64(image);
a.click();
};
};

1 comment on commit 5b4779b

@vercel
Copy link

@vercel vercel bot commented on 5b4779b Jun 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.