Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use CalcService for easier image resizing Apps
This isn't really some brilliant discovery, but it's more like a realization of the power behind OS X...

CalcService is a great add-on which allows you to calculate the result of a mathematical expression right within a Cocoa app. I've used this for some time in my personal finance program: to add up a couple of figures, highlight them, press the keystroke equivalent, and boom -- the result is there. No need to open a separate calculator, etc.

Just recently it occurred to me that you could put this to use in many other ways. How many people resize images on a regular basis? How many people have to quickly pull out a piece of scratch paper to figure out what half (or a third, etc.) of 537 pixels is? If you're working in a Cocoa image editing/manipulation application (such as Keynote or OmniGraffle), and your image-resizing controls are text fields, just take the number of pixels already listed, type *.5, highlight and invoke the service, and boom -- your image is resized by half!

Simple, but saves a lot of time...
    •    
  • Currently 2.33 / 5
  You rated: 4 / 5 (3 votes cast)
 
[5,195 views]  

Use CalcService for easier image resizing | 6 comments | Create New Account
Click here to return to the 'Use CalcService for easier image resizing' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use CalcService for easier image resizing
Authored by: jtoonen on Jan 05, '04 03:12:52PM

BTW this works also but a bit different with the SAFARI search field. Just type and equation and Google will show you the correct result. f.e. 2*5 becomes 10. This also works for pi and sin(30).



[ Reply to This | # ]
Use CalcService for easier image resizing
Authored by: adrianm on Jan 05, '04 03:34:47PM
Panther has a built-in service which is; evaluate an applescript expression and replace it with result.

On my Mac, it is associated with Cmd+*

Now, 3*12 happens to be a valid expression, so type it into any Cocoa text field, select it, type Cmd+* and it is replaced with 36.

Of course, as it is evaluating an applescript expression, you can be quite inventive, eg length of "Hello" returns 5, random number returns (eg) 0.628961449436, etc.

Another use: get environment variables: system attribute "HOME" for me returns /Users/adrian.

Very handy and I use it all the time.

[ Reply to This | # ]

Use CalcService for easier image resizing
Authored by: semios on Jan 05, '04 06:55:44PM

Woah. That's pretty damn cool.

Services feel weird. I don't understand them yet, really. I feel the same way about them as I felt about pipes in DOS. They're there and they have some limited utility, but is that all they're there for? It wasn't until I saw them in unix that I really understood what good they were. Maybe if I saw Services in NeXT I'd understand.



[ Reply to This | # ]
Use CalcService for easier image resizing
Authored by: aranor on Jan 07, '04 04:38:58PM

How's yours associated with Cmd+*? It's not for me (I assume you mean Get result of applescript)



[ Reply to This | # ]
Use CalcService for easier image resizing
Authored by: NeutronMonk on Jan 08, '04 12:51:47PM

When I first tried the command+* keystroke with a simple calculation in TextEdit, it did nothing. By about the third try (I'm persistent!), the keystroke launched Script Editor, and the script completed. This apparently works only with Script Editor running in the background- at least in my case. In any event, really quite useful.



[ Reply to This | # ]
Use CalcService for easier image resizing
Authored by: readparse on Jan 20, '04 08:58:09AM
OS X missed it's chance to give me a calculator, with that gawdawful slow thing that came in Jaguar and previous. I eventually realized that Google is also a calculator, evaluating expressions just like this hint discusses, with all kinds of constants also (pi, "mass of earth", etc) and units conversion ("2.34 miles in inches," for example, or "9 gallons in tablespoons").

Anyway, I noticed that Calculator.app is better than it used to be, it seems, but Google has taken over. Well, except for quick and very simple calculations at the command line, in which case I use "bc" (basic calculator):

echo "3456 * 54" | bc

[ Reply to This | # ]