logo
down
shadow

How to get base64 image data without call canvas toDataURL?


How to get base64 image data without call canvas toDataURL?

By : user2956742
Date : November 22 2020, 03:03 PM
around this issue I finally find the solution which is to use an open source project: canvg
code :


Share : facebook icon twitter icon
Scale a Canvas so that the base64 toDataURL() is scaled as well

Scale a Canvas so that the base64 toDataURL() is scaled as well


By : Hal
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I'm building a chrome extension to save screenshots of the webpage. I've gotten the screenshot all pieced together into an HTML5 canvas element. , If you want to get a scaled down :
Why does canvas.toDataURL() not produce the same base64 as in Ruby for an image?

Why does canvas.toDataURL() not produce the same base64 as in Ruby for an image?


By : rzb
Date : March 29 2020, 07:55 AM
To fix the issue you can do When you load the image in Ruby the binary file without any modifications will be encoded directly to base-64.
When you load an image in the browser it will apply some processing to the image before you will be able to use it with canvas:
Security violation on Canvas.ToDataUrl with Base64 Image

Security violation on Canvas.ToDataUrl with Base64 Image


By : Malgos
Date : March 29 2020, 07:55 AM
I hope this helps you . The problem is that some browsers are very strict when using SVG with canvas, incl. for example IE.
As your branding logo is SVG it will taint the canvas in these browsers.
canvas.toDataURL() results black image by trying to resize base64 string

canvas.toDataURL() results black image by trying to resize base64 string


By : DylanS
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further You will need to wait onload event after that use global variable to save data and call upload function on the end .
Try this :
code :
function exportImg(val){  
                var imageData = $('#image-cropper').cropit('export', {originalSize: true});
                imageData = imageData.replace(/^data:image\/[a-z]+;base64,/, "");

                  resize(imageData);

        }


var SendWhenisReady = function(imageDataRes){

 $.post('php/upload.php', { imageDataRes: imageDataRes });

};

function resize(base64){
            // Max size for thumbnail
            var maxWidth = 900;
            var maxHeight = 900;

            // Create and initialize two canvas
            var canvas = document.createElement("canvas");
            var ctx = canvas.getContext("2d");
            var canvasCopy = document.createElement("canvas");
            var copyContext = canvasCopy.getContext("2d");

            // Create original image
            var img = new Image();
            img.src = base64;

            img.onload = function(){

                // Determine new ratio based on max size
                var ratio = 1;
                if(img.width > maxWidth) {
                    ratio = maxWidth / img.width;
                }
                else if(img.height > maxHeight) {
                    ratio = maxHeight / img.height;
                }


            // Draw original image in second canvas
            canvasCopy.width = img.width;
            canvasCopy.height = img.height;
            copyContext.drawImage(img, 0, 0);

            // Copy and resize second canvas to first canvas
            canvas.width = img.width * ratio;
            canvas.height = img.height * ratio;
            ctx.drawImage(canvasCopy, 0, 0, canvasCopy.width, canvasCopy.height, 0, 0, canvas.width, canvas.height);


                 alert(canvas.toDataURL());
                 window['imageDataRes'] = canvas.toDataURL();
                 SendWhenisReady(window['imageDataRes'])
            }



        }
How to use canvas.toDataURL() to get base64 of image in Adobe AIR?

How to use canvas.toDataURL() to get base64 of image in Adobe AIR?


By : user3920324
Date : March 29 2020, 07:55 AM
Any of those help Adobe AIR enforces same origin for images used in the canvas API. Once you've used something from another domain in your canvas, you can't get pixel data back out of it. However, you can make use of the Loader class to get the pixel data, and convert it into a canvas ImageData.
For example:
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org