Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>First:</strong><br> Hard limitations would depend on the browser, not the canvas API.<br> Even then, browsers are always trying to <em>improve</em> that performance, so that number would always be changing.<br> But with WebGL and Canvas being used to make games, texture atlases / sprite atlases are HUGE .jpg/.png files.<br> Chances are very, very good that your images are smaller, and I've frequently used 4MB/5MB/16MB images in canvas for demonstrations.<br> A huge image (or dozens of them) might crash the tab, if it's big enough, but until that time, canvas hasn't really complained to me.</p> <p><strong>Second:</strong><br> There are security-limitations.<br> Editing photos in <code>canvas</code> comes down to what browser you're on, and whether the file is on the same domain as your website or not.</p> <p><strong>Third:</strong><br> When you say that <em>"large files don't work, but they do sometimes..."</em><br> ...that leads me to believe that your <strong><em>image-loading method</em></strong> is faulty.</p> <p>If you do something like this:</p> <pre><code>var canvas = document.createElement("canvas"), context = canvas.getContext("2d"), img = new Image(); img.src = "//mydomain.com/myimg.png"; context.drawImage(img, 0, 0, img.width, img.height); </code></pre> <p>...or anything else which isn't either event-based or callback-based,<br> then your problem has nothing to do with <code>canvas</code> and has everything to do with callbacks, and that you're trying to draw the image to the canvas before the image is done loading. </p> <p>If your browser has already cached a copy of the large image, or if a small image only takes a fraction of a second to download, then there's no problem.</p> <p>If you try downloading an 18MB image, and draw it to the canvas as soon as you set the url for the image, then you're going to get a blank screen, because it hasn't finished loading.</p> <p>Instead, you need to wait for the image to finish loading, and <strong><em>then</em></strong> draw it to the canvas when it's ready.</p> <pre><code>var canvas = document.createElement("canvas"), context = canvas.getContext("2d"), image = new Image(); image.onload = function () { var img = this, width = img.width, height = img.height; canvas.width = width; canvas.height = height; context.drawImage(img, 0, 0, width, height); document.body.appendChild(canvas); }; image.src = "//mydomain.com/path-to-really-huge-image.png"; </code></pre> <p>Now it could be a 16MP image. Nothing will happen until the file is done loading.<br> Then, the <code>onload</code> event fires, and does the rest of the setup. </p> <p>You could make it more abstract, and turn it into a nifty program, but it feels like this is the key piece you might be missing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload