GithubHelp home page GithubHelp logo

blueimp / javascript-canvas-to-blob Goto Github PK

View Code? Open in Web Editor NEW
1.5K 1.5K 395.0 890 KB

JavaScript Canvas to Blob is a function to convert canvas elements into Blob objects.

Home Page: https://blueimp.github.io/JavaScript-Canvas-to-Blob/test/

License: MIT License

JavaScript 91.01% HTML 7.01% Shell 1.98%

javascript-canvas-to-blob's People

Contributors

bdusell avatar blueimp avatar claudiodangelis avatar dantman avatar farfeduc avatar hinathan avatar joewood avatar magkiller avatar wetoolaguer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

javascript-canvas-to-blob's Issues

Problems with AMD Loader

I was having problems with the AMD loader for this repo and your Load-image repo (require.js mismatch error). I switched to the intro/outro pattern that you have in your fileupload.js script, which fixed the problem.

I think you should consider copying the same style.

Sample intro copied for relevance.

(function (factory) {
    'use strict';
    if (typeof define === 'function' && define.amd) {
        // Register as an anonymous AMD module:
        define([
            'jquery',
            'jquery.ui.widget'
        ], factory);
    } else {
        // Browser globals:
        factory(window.jQuery);
    }
}(function ($) {
    'use strict';
    ...

Convert dataUrl to Blob

Can this function somehow be used to convert a dataUrl into a blob?

Does it makes any difference whether I do

  1. Canvas > toBlob()

or

  1. Canvas > toDataUrl() > toBlob()

Thanks for help.

v2.x to v3.x

Hi,
I've been looking for changelogs without success.
No way to know if v3 api has breaking changes

Unable to browserify

I get a module "blueimp-canvas-to-blob" not found when writing a bundle in gulp through browserify ...

It is an error if there is a line break code

The Base64, for line feed may enter every 76 characters, you must remove the line breaks in the code of standard MIME.
Trouble, I spent time in the processing of new-line code. How do may be to remove the new line code in a separate process from the original,
I think it's nice to have the treatment in your plugin.
What would you say?
I described my suggestion below.

// For line feed may enter every 76 characters, 
// remove the line break code if it was obtained from the mail object in the standard MIME.
if (dataURI.split(',')[0].indexOf('base64') >= 0) {
    // Convert base64 to raw binary data held in a string:
    byteString = atob((dataURI.split(',')[1]).replace(/\s/g, ''));
} else {
    // Convert base64/URLEncoded data component to raw binary data:
    byteString = decodeURIComponent((dataURI.split(',')[1]).replace(/\s/g, ''));
}

Uncaught (in promise) DOMException: Failed to execute 'toBlob' on 'HTMLCanvasElement': Tainted canvases may not be exported.

Hello,
When I am trying to use toBlob it gives me " Uncaught (in promise) DOMException: Failed to execute 'toBlob' on 'HTMLCanvasElement': Tainted canvases may not be exported."

I am trying this :

  // looping through thumbnail list to update thumbnail
                thumbnails.forEach(function(item) {
                    // converting canvas to blob to get short url
                    console.log('canvas', item.canvas)

                    //item.canvas.toBlob(blob => item.data = URL.createObjectURL(blob), 'image/jpeg');
                    if (item.canvas.toBlob) {
                        item.canvas.toBlob(function (blob) {
                            // Do something with the blob object,
                            // e.g. create multipart form data for file uploads:
                            var formData = new FormData()
                            formData.append('file', blob, 'image.jpg')
                            console.log('formData', formData)
                            // ...
                        }, 'image/jpeg')
                    }

                    // deleting unused property
                    delete item.canvas;
                });

Do you know why I am facing this issue, OR how can I fix this?

Calculation of bytes

Using the canvas-to-blob.min.js, calculating image bytes always gives far below the actual image size.

Image:
6.30 MB (6291456 Bytes)

Options:
maxFileSize: 4000000, //4MB

Result with canvas-to-blob:
fileSize: 271959 options.maxFileSize: 4000000
Should return the error "File is too large". What is going on?

Result without canvas-to-blob:
fileSize: 6609149 options.maxFileSize: 4000000

Some jpg images not working on iPOD 4

Some jpg files are resized with 0 bytes on an iPOD 4 that is working fine on iPAD 2. It's always the same images that don't work for my testing set of 54 files. Are you aware of any trouble with the iPOD to run your code correctly for some type of images.

Thanks

toBlob() not working correctly on Safari iOS7

I tried the following

canvas.toBlob(function (blob) {
                    alert(blob.size);

                }, 'image/png'
            );

It turns out the the size is very small about 9000 bytes. This is far to low for images made on the iPhone.

Do you have any idea on that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.