Best (easiest fasterest most efficient) Means to Load an image and extract a subimage

2 views
Skip to first unread message

David Hoerl

unread,
Sep 29, 2011, 9:20:22 AM9/29/11
to Quartz Dev List
The last thread was starting to go all over the place, so thought I'd
refocus it on my specific task.

My goal is to create a script based Service in Automator that I can post
for non-developers - so everything I use has to be on a base Snow
Leopard or even Lion machine sans Xcode.

The script will at the end crop an image to get just a portion of the
left side of the image. sips cannot do this - it only crops from the
middle.

It appears that at least one scripting language, Python, can load
Quartz, and then let me access the functionality from that language.
However, the only "Quartz" I can find on my system in a Python folder in
/Developer (using Spotlight)?

I did see that the load took a few seconds (from Quartz import *
), and so I suppose that the script, having to load Quartz at each
invocation, is going to be slower than it would be using an executable
(like sips) - but at least it would be possible!

Sooooo - a few questions for the audience:

1) Is the Quartz plugin for Python on a base system? If so where is it?

2) What other scripting language options do I have, and are there
example scripts anywhere to be found (or readmes etc) on using Quartz?

David


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (Quart...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/quartz-dev-garchive-50095%40googlegroups.com

This email sent to quartz-dev-g...@googlegroups.com

Kyle Sluder

unread,
Sep 29, 2011, 10:55:10 AM9/29/11
to David Hoerl, Quartz Dev List
On Sep 29, 2011, at 6:20 AM, David Hoerl <dho...@mac.com> wrote:

> My goal is to create a script based Service in Automator that I can post for non-developers - so everything I use has to be on a base Snow Leopard or even Lion machine sans Xcode.

Is there a reason you can't just build an executable and bundle it in your action? What's the real goal here: to have a service that does your cropping, or to have a service whose implementation can be read and understood by non-developers?

>
> It appears that at least one scripting language, Python, can load Quartz, and then let me access the functionality from that language. However, the only "Quartz" I can find on my system in a Python folder in /Developer (using Spotlight)?

Quartz.framework lives in /System/Library/Frameworks. It is a core component of Mac OS X that is installed on all machines. /Developer might contain symlinks to it in the current platform SDK, or it can contain shell copies of the header files from previous OS's versions of Quartz.framework in their SDKs to facilitate writing backwards-compatible code.

>
> I did see that the load took a few seconds (from Quartz import *
> ), and so I suppose that the script, having to load Quartz at each invocation, is going to be slower than it would be using an executable (like sips) - but at least it would be possible!
>
> Sooooo - a few questions for the audience:
>
> 1) Is the Quartz plugin for Python on a base system? If so where is it?

There is no Quartz plugin, per se. `import Quartz` loads Quartz.framework and creates a module containing functions for all the functions found in Quartz.framework. There is some glue code that makes this possible, and this glue code relies on BridgeSupport. But conceptually speaking, you should think of `import Quartz` as the Python equivalent of `dlopen("/System/Library/Frameworks/Quartz.framework/Quartz")`.

>
> 2) What other scripting language options do I have, and are there example scripts anywhere to be found (or readmes etc) on using Quartz?

Ruby was mentioned previously.

--Kyle Sluder _______________________________________________

easco

unread,
Sep 29, 2011, 10:59:11 AM9/29/11
to David Hoerl, Quartz Dev List


On Sep 29, 2011, at 08:20 AM, David Hoerl <dho...@mac.com> wrote:

The last thread was starting to go all over the place, so thought I'd
refocus it on my specific task.

My goal is to create a script based Service in Automator that I can post
for non-developers - so everything I use has to be on a base Snow
Leopard or even Lion machine sans Xcode.

The script will at the end crop an image to get just a portion of the
left side of the image. sips cannot do this - it only crops from the
middle
 
OK since you're starting with Automator.  You could make calls directly from AppleScript to Cocoa (Starting in Snow Leopard).  You should be able to accomplish this task using some code based off of NSImage directly through AppleScript if that is your desire.

See:


There should also be videos in the WWDC 2010 set (if you can still get to them) about scripting using AppleScript 

It appears that at least one scripting language, Python, can load
Quartz, and then let me access the functionality from that language.
However, the only "Quartz" I can find on my system in a Python folder in
/Developer (using Spotlight)?

I did see that the load took a few seconds (from Quartz import *
), and so I suppose that the script, having to load Quartz at each 
invocation, is going to be slower than it would be using an executable 
(like sips) - but at least it would be possible!

Sooooo - a few questions for the audience:

1) Is the Quartz plugin for Python on a base system? If so where is it?

2) What other scripting language options do I have, and are there 
example scripts anywhere to be found (or readmes etc) on using Quartz?

You may also call Quartz from Ruby using RubyCocoa (http://sourceforge.net/projects/rubycocoa/) or MacRuby (http://www.macruby.org/)
You may call it from Perl using CamelBones (http://camelbones.sourceforge.net/)
And Python using PyObjC (http://pyobjc.sourceforge.net/)

Documentation for each bridge should be available at their web site.

Scott

Kyle Sluder

unread,
Sep 29, 2011, 11:03:04 AM9/29/11
to David Hoerl, Quartz Dev List
On Thu, Sep 29, 2011 at 7:55 AM, Kyle Sluder <kyle....@gmail.com> wrote:
> On Sep 29, 2011, at 6:20 AM, David Hoerl <dho...@mac.com> wrote:
>
>> My goal is to create a script based Service in Automator that I can post for non-developers - so everything I use has to be on a base Snow Leopard or even Lion machine sans Xcode.
>
> Is there a reason you can't just build an executable and bundle it in your action? What's the real goal here: to have a service that does your cropping, or to have a service whose implementation can be read and understood by non-developers?

Answering my own question here: I'm conflating Automator actions with
Automator workflows. I don't actually know if you can bundle an
executable as part of a workflow.

Reply all
Reply to author
Forward
0 new messages