set this_file to choose file without invisibles
try
tell application "Image Events"
-- start the Image Events application
launch
-- open the image file
set this_image to open this_file
-- perform action
scale this_image by factor 0.5
-- save the changes
save this_image with icon
-- purge the open image data
close this_image
end tell
on error error_message
display dialog error_message
end try
Check your IP address
A simple IP utility from ScriptBuilders (accessible from the Scriptbuilders site) lets you quickly check your external IP address and copy it to your clipboard for tasks such as setting up a VPN or supporting a remote access connection.
Add lyrics to iTunes
There are hundreds of iTunes AppleScripts out there on sites such as Doug's AppleScripts for iTunes. For example, you can make tracks "bookmarkable" so they resume playing wherever they left off or pick items on an iPod so they're copied into an iTunes folder.
One of the more amusing is a script that automatically searches a database on the Web and adds a text version of a song's lyrics into iTunes. Not all songs work properly, but when a match is found, you get to see full lyrics downloaded into iTunes.
iTunes volume fade-in and fade-out
For audiophiles who prefer that their music fade in when starting up and fade out when a tune is paused or restarted manually in mid-play, O'Reilly's MacDevCenter site offers several iTunes scripts that do just that, either with or without dialog boxes.
Quick image manipulation
I'd wager that a fair number of AppleScript users would be surprised to learn that they don't need an app like Photoshop in order to script things like rotating or resizing an image.
The following script from the book Apple Training Series: AppleScript 1-2-3 resizes an image to 50% of the original.
Code
Of course, Photoshop gives you much more control over how images are sized, so this isn't a great technique to size images for printing or publication. However, for a quick e-mail attachment, it should be fine. There are also versions on the same Web page to size for maximum width or height, with user input setting the parameters.
Code
set this_file to choose file without invisibles
set the target_length to 640
repeat
display dialog "Enter the target length " & "and choose the dimension of the " & "image to scale to the target length:" default answer target_length buttons {"Cancel", "Height", "Width"}
copy the result as list to {target_length, target_dimension}
try
set the target_length to the target_length as number
if the target_length is greater than 0 then
exit repeat
else
error
end if
on error
beep
end try
end repeat
try
tell application "Image Events"
-- start the Image Events application
launch
-- open the image file
set this_image to open this_file
-- get dimensions of the image
copy dimensions of this_image to {W, H}
-- determine scale length
if the target_dimension is "Height" then
if W is less than H then
set the scale_length to the target_length
else
set the scale_length to (W * target_length) / H
set the scale_length to
round scale_length rounding as taught in school
end if
else -- target dimension is Width
if W is less than H then
set the scale_length to (H * target_length) / W
set the scale_length to
round scale_length rounding as taught in school
else
set the scale_length to the target_length
end if
end if
-- perform action
scale this_image to size scale_length
-- save the changes
save this_image with icon
-- purge the open image data
close this_image
end tell
on error error_message
display dialog error_message
end try
Getting the most out of AppleScript
- 10 Hot Big Data Startups to Watch
- 11 Unique Uses for Google Glass, Demonstrated by Celebs
- How to Export Your Google Reader Account
- How to Better Engage Millennials (and Why They Aren't Really so Different)
- Telltale signs of ATM skimming
- 20 security and privacy apps for Androids and iPhones
- Big screen con artists: 7 great movies about social engineering
- IT Certification Study Tips
- Register for this Computerworld Insider Study Tip guide and gain access to hundreds of premium content articles, cheat sheets, product reviews and more.
- Software Asset Management: Ensuring Today's Assets Today's trends like BYOD and SaaS are new and exciting in terms of how they will help make our jobs more productive but...
- Software Asset Management: Getting Started Find out what steps to take that can lead your organization down the smooth path to SAM deployment.
- ESG Lab Validation of QLogic's Caching SAN Adapter ESG details the results of their testing of QLogic's new 10000 Series 8Gb Fibre Channel Adapter with a focus on scalable database performance...
- Deliver Customer Value with Big Data Analytics Big Data requires that companies adopt a different method in understanding today's consumer. Read this white paper to learn why Big Data is...
- The ServiceNow Service Automation Platform During this webinar, you will discover how ServiceNow is enabling organizations to increase their competitive agility, user satisfaction and productivity, all while enhancing...
- Building a Business Case for Service Management & Automation As an IT infrastructure and operations (I&O) leader you understand the business and IT impact of service management and automation (SMA). All Operating Systems White Papers | Webcasts
From invoking 'God Mode' to hacking the lock screen, here are 10 ways to make Windows 8 act the way you want. Read more...