Quote from
luishp on March 22, 2023, 7:31 pm
@smartmedia if the image is located in the same domain than your app (no CORS) just use something like this:
neoDownloadURL "./img/my-image.jpg"
Else you can try:
BeginJS
// get the image element by its ID
const image = document.getElementById("Image1");
// create a canvas element and draw the image onto it
const canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
const ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
// convert the canvas to a data URL
$App.dataURL = canvas.toDataURL("image/jpeg");
EndJS
Wait 500
neoDownloadData "[dataURL]" "my-image.jpg" "image/jpeg"
EndWait
Let me know if it works.
Regards.
@smartmedia if the image is located in the same domain than your app (no CORS) just use something like this:
neoDownloadURL "./img/my-image.jpg"
Else you can try:
BeginJS
// get the image element by its ID
const image = document.getElementById("Image1");
// create a canvas element and draw the image onto it
const canvas = document.createElement("canvas");
canvas.width = image.width;
canvas.height = image.height;
const ctx = canvas.getContext("2d");
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
// convert the canvas to a data URL
$App.dataURL = canvas.toDataURL("image/jpeg");
EndJS
Wait 500
neoDownloadData "[dataURL]" "my-image.jpg" "image/jpeg"
EndWait
Let me know if it works.
Regards.
smartmedia has reacted to this post.