eligrey / eligrey/FileSaver.js

On the mobile side, I pass in the base64 value and save it as jpeg, but when I download it on the phone, it is not an image file, but other files, and it has not been downloaded yet. Why is this?

Open
#537 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
22k
Forks
4.3k
PR merge metrics
No merged PRs in 30d

Description

On the pc side, downloading the picture is no problem. On the mobile side, I pass the base64 value and save it as jpeg, but when I download it on the phone, it is not an image file, but other files, and it has not been downloaded yet. Why is this?

demo:

html2canvas(shareContent, opts).then(function(canvas) {
// canvas.setAttribute("id", "thecanvas");

var context = canvas.getContext("2d");

context.mozImageSmoothingEnabled = false;
context.webkitImageSmoothingEnabled = false;
context.msImageSmoothingEnabled = false;
context.imageSmoothingEnabled = false;


var img = Canvas2Image.convertToJPEG(
canvas,
canvas.width,
canvas.height
);

// var detail = document.getElementsByName(".wrap");
var detail = document.querySelector(".png-content");
detail.appendChild(img);

$(img)
.css({
width: canvas.width / 2 + "px",
height: canvas.height / 2 + "px"
})
.addClass("f-full");

canvas.toBlob(function(blob) {
saveAs(blob, "pretty image.jpeg");
});

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.