5 examples of 'html2canvas cdn' in JavaScript

Every line of 'html2canvas cdn' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
35function downloadCanvas(link, canvasId, filename) {
36 link.href = canvas.toDataURL();
37 link.download = filename;
38}
45async function urlToCanvas(url: string, size: number): Promise {
46 return new Promise(resolve => {
47 const img = new Image();
48
49 img.crossOrigin = 'anonymous';
50
51 img.addEventListener('load', () => {
52 resolve(drawIcon(size, img));
53 });
54
55 img.addEventListener('error', () => {
56 console.error('Image not found', url);
57 resolve(drawIcon(size));
58 });
59
60 img.src = url;
61 });
62}
34function cdnImage (url, width) {
35 return 'https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url=' + url + '&container=focus&refresh=2592000&resize_w=' + width
36}
817function imagetocanvas(img, w, h, name, folder) {
818 var dimensions = resize(
819 img.width || settings.w,
820 img.height || settings.h,
821 w, h);
822
823 $canvas.width = w;
824 $canvas.height = h;
825
826 if (settings.crop) {
827 c.width = dimensions.w;
828 c.height = dimensions.h;
829 dimensions.x = 0;
830 dimensions.y = 0;
831 }
832 if (settings.background !== 'transparent') {
833 ctx.fillStyle = settings.background;
834 ctx.fillRect(0, 0, w, h);
835 }
836
837 ctx.drawImage(
838 img, dimensions.x, dimensions.y, dimensions.w, dimensions.h
839 );
840 addtothumbslist(name, folder);
841}
52function urlToCanvas(url, done) {
53 var canvas = document.createElement('canvas');
54 var ctx = canvas.getContext('2d');
55 var img = new Image();
56 img.onload = function() {
57 canvas.width = img.naturalWidth;
58 canvas.height = img.naturalHeight;
59 ctx.drawImage(img, 0, 0);
60 done(null, canvas);
61 };
62 img.onerror = function(e) {
63 done(e);
64 };
65 img.crossOrigin = 'anonymous';
66 img.src = url;
67}

Related snippets