Fix copied images from Evernote

When you copy an image in Evernote by selecting it and choosing "Copy Image", iClip will only show a "?" instead of the image.

The reason for that is that Evernote does not, as it should, put an actual images into the clipboard, but only a reference to an image file in a temporary folder. iClip will store that reference correctly so that you can still paste it back from iClip into other applications.

However, if you then quit Evernote, the temporary image files get deleted from your disk. After that, you cannot paste the clippings any more because the file is gone.

To fix this, you have to make iClip store the actual image, not just the reference to the file.

This can be accomplished by adding some Applescript code to iClip.

Prepare scripting by installing the "iClip Events" script

Download the iClip Events.scpt file from http://iclipapp.com/dl/scripts/Action%20Scripts/ and place it into iClip's Scripts folder as explained on the Scripting page.

Add the Evernote handling code to the "iClip Events" script

Open the  iClip Events.scpt file in Script Editor (which is inside the Utilities folder, inside the Applications folder).

Scroll to the end of the handleAddedClipping function, where it says end handleAddedClipping, and insert the following text before that line:

	set theClipping to current clipping
	if theClipping's app name is "Evernote" then
		-- collect the file paths of the given clipping
		set fileRef to theClipping's first clip item's file reference
		if fileRef is not missing value then
			-- create a new clipping from the file's data
			set itsProps to properties of theClipping
			set newclip to make new clipping with data fileRef with properties itsProps
			if newclip's kind is file alias then
				-- it could not be loaded as something iClip could store
			else
				-- iClip could load it as an image or text
				-- now replace the clipping in the bin
				set itsSet to container of theClipping
				set pos to position of theClipping
				delete theClipping -- dispose of the old clipping
				set contents of bin pos of itsSet to newclip -- put new clipping into the bin
			end if
		end if
	end if

Then click on the Compile button at the top of the window. The text should then look like this:

Save and Test

If the script code looks correctly inserted, save the script and then test if it works by using Copy Image in Evernote.