I'm currently building a very bare bones web app, that had the requirement of being able to copy an image while broswing the web, and then pasting it onto my page.
I know that this type of functionality IS possible - as I've pasted images into gmail while writing messages, and into Tumblr (I believe they use TinyMCE as their editor).
After long searching - I've been saddened by the poor quality of explanation for the available solutions out there.
This is what I've gathered:
$(document).bind('paste', function(e){
console.log(e);
})
Inspecting the event object, it seems that data is only included when there is text (in Chrome anyways).
I am aware that IE has a clipboardData object which gives you access to the clipboard contents.
I've also heard of possible solutions using Flash, Java Applets, and HTML 5 Canvas - but I haven't yet been able to find good write ups explaining those solutions.
Anyone done this successfully, and can suggest best practices?
Ctrl + V (for Windows) or Cmd + V (for Mac) for pasting content. You can use this keyboard shortcut for text, images, files, folders, and links.
The Canvas Size command is used for adding space around a photo or essentially cropping the image by reducing the available space. More Detail: For example, let's assume you have an image that is currently sized at 8-inches by 12-inches at 300 pixels per inch (2,400 by 3,600 pixels).
This works fine in Chrome. Here's a live example supporting getting image data in pure JavaScript with no servers involved: http://strd6.com/2011/09/html5-javascript-pasting-image-data-in-chrome/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With