Questions tagged [todataurl]

a HTMLCanvasElement method that returns the data URI value of a canvas element

HTMLCanvasElement.toDataURL() is a method that returns the value of a element as a string.

Parameters

HTMLCanvasElement.toDataURL() accepts to optional parameters:

  • type: specifies the image type to be returned
  • encoderOptions: specifies the quality of the image to be returned

Resources

Related Tags

208 questions
2
votes
0 answers

canvas.toDataURL() returns black image in some cases

Why does calling toDataURL() on a canvas return a solid black image in some cases? E.g. try this test case: Open this URL in chrome: https://www.shadertoy.com/embed/Ms23DR And then type in the js…
2
votes
2 answers

image to base64 in javascript and c# (frontend and backend) is different

I am trying to convert an image to base64 to upload it on sharepoint site but it is throwing 400:bad request error. when i checked properly then i found out that the base64 i am sending is endcoded by javascript and it is different than what is…
Darpan Pathak
  • 86
  • 1
  • 6
2
votes
1 answer

Uploading image bytes instead of base64 representation

Given a canvas in javascript, the normal workflow to save to a backend server is the following: Create canvas element Draw / modify canvas Call canvas.toDataURL() Upload this base64 representation of the canvas to your backend server (basic…
Tim D
  • 195
  • 1
  • 10
2
votes
1 answer

Javascript Pdfjs Canvas to Img

I've a problem to convert canvas to img.. What's the best approach to use toDataURL() and insert it in img src? when I launch the script it gives me the correct canvas but the img is blank.. this is my code:
2
votes
1 answer

toDataURL() returning incorrect url

I am attempting to create a pdf of a page from my meteor powered site. The page contains quite a bit of styling and some d3 charts. I have added chipcastledotcom:jspdf and new3rs:html2canvas to accomplish my goal. My plan is to use html2canvas…
John Cast
  • 1,771
  • 3
  • 18
  • 40
2
votes
2 answers

Why isn't image onload firing when I try to create a new image into canvas?

I want to grab a SVG and save it as PNG (from a Chart plugin that creates SVG), and I thought I've figured out how to achieve this... I've been looking around why onload functions are not firing, but still I can't understand why this code below does…
bestprogrammerintheworld
  • 5,417
  • 7
  • 43
  • 72
2
votes
1 answer

Canvas toDataURL without alpha channel

I'd like to resize uploaded images in browser. I am using canvas to draw the uploaded image to canvas and then resize it, and use the result from toDataURL method. Simplified code (without upload parts) looks something like this: var canvas =…
nutrija
  • 317
  • 2
  • 8
2
votes
1 answer

Paperjs rasterize activeLayer with bounds from view

I've got this fiddle, where I'd like to achieve sort of rasterized thumbnail of canvas view. Everything works ok until some paths overflow view bounds and those overflowed parts also get exported into thumbnail, what is not desired. Only parts that…
ma2s
  • 1,312
  • 1
  • 11
  • 24
2
votes
1 answer

Django/Python/toDataURL return a response with the string from toDataURL

I have saved in a database a string return by the javascript method toDataURL. An exemple is available here: http://pastebin.com/0Qu8rngD I need to return the image in a django response. Something like: return HttpResponse(image,…
2
votes
1 answer

how to send dataURL Picture via email

For a web project, I want to send a picture which I get from a canvas via dataURL via email to upload it direct to tumbler. I can get the dataURL and download the picture with function download() { var dt = scope.toDataURL('image/png'); this.href =…
1
vote
0 answers

HTMLCanvasElement.toDataURL() JPEG quality different on Apple and Windows

I have a canvas, in memory, not part of the DOM, that I write image bytes to. The image size is 1008 x 756 (a 4032x3024 photo reduced to 1/4 size). I then call canvas.toDataUrl('image/jpeg',.8) to output a JPEG image at 80% quality. On windows, the…
1911TRP
  • 11
  • 2
1
vote
0 answers

Image canvas toDataURL function is not wokring on ios

I have a drawImage function in my application which loads the image from a blob and then from that image object calls the toDataURL function for the canvas to draw image. The problem is that this code works on android and browser but not working on…
1
vote
1 answer

How to export a gif canvas to gif image with jquery and konva.js

i make a gif canvas with multiple picture, now i want to export it but canvas is not export into gif its only export into png format my code is ` var c_img = new Konva.Image({ image: imageObj, …
jawad
  • 13
  • 6
1
vote
1 answer

Created Image of Canvas haven't get appended to html container

I have a canvas. Now i want to make an image of the canvas. This function i already developed. I've got an image with the right src-attribute. But if i want to append this image-element to the html-container, it doesn't works. Nothing happens. I…
Stefan
  • 61
  • 6
1
vote
0 answers

How to get dataURL of Salesforce ContentVersion in LWC?

I am trying to get dataURL of Salesforce ContentVerison using canvas.toDataURL in LWC method but I am getting the following CORS policy error: "error image" LWC html code: