Monday, January 28, 2013

AppleScripting Evernote > Embedded Image Scaler

AppleScripting Evernote > Embedded Image Scaler:
AppleScripting Evernote  Embedded Image ScalerI'm a big fan of Evernote. I use it for archiving ideas, writing articles and blog posts, and lots more. I often insert screenshots and other large images into my notes. Screenshots can be pretty big, and I usually don't want giant images filling up my notes. I keep wishing Evernote offered a way to resize embedded images, so I could insert thumbnails. At the moment, it doesn't. So, I decided to write my own app to resize embedded images. Here's how you can do the same...

Creating the Script App




My script app uses Image Events, a background app in OS X, to do the scaling. So, no third-party software (other than Evernote) is needed for this to work.




Note: If you have any trouble following along, don't worry, you can download the complete script app here.




1. Launch AppleScript Editor and create a new script document containing the following script:












If you're familiar with AppleScript, then you'll notice this script uses an open handler, making it a droplet. When triggered to process an embedded image in an Evernote note, the image is actually passed as if it was dropped on the script app.




2. Save the script as an application named Evernnote > Scale Embedded Images to your Applications folder or another folder of your choice.


AppleScripting Evernote  Embedded Image Scaler


3. Go to the saved script app and Control+Click on it to reveal the Finder's contextual menu. Choose Show Package Contents to view the contents of the saved app bundle.


AppleScripting Evernote  Embedded Image Scaler


4. Navigate to the Contents folder within the script's bundle and open the Info.plist file in TextEdit, TextWrangler, or your other favorite text editor.


AppleScripting Evernote  Embedded Image Scaler


5. Change the CFBundleDocumentTypes key's array to the following:




This Info.plist change sets the script app to only accept JPEGs, PNGs, and TIFFs, and for the script app to appear as an image editor. Image Events can process other types of images too, including BMP, GIF, PSD, and PICT. So, if you think you may be embedding those types of images in your notes, go ahead and add extensions for them too.




6. Save and close the edited Info.plist.




You're done. The script app is ready for use.




Resizing Embedded Images in Evernote




Please note that your script app scales embedded images in Evernote notes. When an image is scaled, you can't revert back to the unscaled version. So, be pretty darn sure you want to scale an image before triggering the script.




1. Open an Evernote note containing an embedded image.


AppleScripting Evernote  Embedded Image Scaler


2. Control+Click on an embedded image and choose Open With. You should see your script app in the list of supported apps. Choose Evernote > Scale Embedded Images.


AppleScripting Evernote  Embedded Image Scaler


Evernote launches the script app and passes it the selected embedded image.




3. When prompted, choose the desired size. Options are Low (320px on the longest side), Medium (640px), or High (1280px). Or, you can select Custom to enter another size.


AppleScripting Evernote  Embedded Image Scaler


The script opens the embedded image, scales it accordingly, and saves it. Evernote detects that the image has been changed, and updates the note to reflect the new scaled version.


AppleScripting Evernote  Embedded Image Scaler


Congratulations, you've just expanded Evernote's feature set. Anytime you want a smaller version of an embedded image, your script app is ready to help. Also, while this script is intended for Evernote, you can use it outside of Evernote too. Just drag and drop JPEGs, PNGs, or TIFFs onto the script app to scale them too. Until next time, happy scripting!


AppleScripting Evernote > Embedded Image Scaler originally appeared on TUAW - The Unofficial Apple Weblog on Mon, 28 Jan 2013 08:00:00 EST. Please see our terms for use of feeds.



Source | Permalink | Email this | Comments

DIGITAL JUICE

No comments:

Post a Comment

Thank's!