خرید بک لینک

Vote count: 0

I have a webapp that uses document.onpaste to support the ability to paste images directly into the app.

I followed instructions from other questions on Stack Overflow (e.g. Paste image to a web page) and my general code looks like this:

document.onpaste = function (event) {
     var items = (event.clipboardData  || event.originalEvent.clipboardData).items;

     var blob = null;
     for (var i = 0; i < items.length; i++) {
       if (items[i].type.indexOf("image") === 0) {
         blob = items[i].getAsFile();
       }
     }

     if (blob !== null) {
       // upload blob
     }
}

However, once my image is uploaded, it is very different from the original image. Notably, it is always 512x512, and is a centered with a large box shadow.

Here is the original image: http://i.stack.imgur.com/P2WNo.jpg

And the pasted / uploaded image: http://i.stack.imgur.com/GDrbG.png

I select the image in Finder, then press cmd+V, and cmd+C into my web app, and the result above gets loaded. Is this an issue with the Mac clipboard?

Thanks for your help!

asked 3 mins ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 11 اسفند 1394 ساعت: 15:00

صفحه بندی