Core Image, Where Art Thou?

S

Spencer Rogers

Lately, I've been developing some image editing functions for my rails
app using RubyCocoa and Core Image. With my novice understanding of
objective-c and the lack of examples for Core Image, much less Core
Image through RubyCocoa, I've had a pretty rough time. The lack of
documentation is rather surprising given the power of Apple's Core Image
suite, and the people that swear by it.

Perhaps I've been looking in all the wrong places? All I've been able
to find is Apple's Core Image Reference Library, a few examples on Red
Artisan's blog, and an image manipulation class built for python. It
seems as though the people clever enough, or the people with enough time
to figure out Apple's Core Image technology and syntax guard their
knowledge closely and only let it out for a price via an app they have
created.

Does anyone here have experience using Core Image in Ruby? I'd really
appreciate any help you could give me, even if it's just directing me to
another forum or hopefully some tutorials or examples. I really have a
lot to learn about Core Image and the syntax/methodology behind it.

As for where I'm at now, I've managed to build a few functions to
convert and resize images but cannot seem to figure out the correct
syntax to rotate an image. Perhaps someone can help me figure this out.

As reference, this is the code I've used to resize an image - a mini
guide to syntax heh.

newImage = self.image
create_core_image_context(newWidth, newHeight)
scale_x, scale_y = scale(newWidth, newHeight)

newImage.affine_clamp :inputTransform =>
OSX::NSAffineTransform.transform do |clamped|
clamped.lanczos_scale_transform :inputScale => scale_x > scale_y ?
scale_x : scale_y, :inputAspectRatio => scale_x / scale_y do |scaled|
scaled.crop :inputRectangle => vector(0, 0, newWidth, newHeight)
do |cropped|
newImage = cropped
end # crop
end # scale
end # clamped

For rotating an image, I've tried various combinations but nothing seems
to work.

newImage.transform :inputTransform =>
OSX::NSAffineTransform.transform.rotateByDegrees(degrees) do |rotated|
newImage = rotated
end # rotated

or even using the affine clamp...

newImage.affine_clamp :inputTransform =>
OSX::NSAffineTransform.transform do |clamped|
clamped.rotateByDegrees :inputAngle => degrees do |rotated|
newImage = rotated
end # rotated
end # clamped



Thanks in advance for any help you all can give me!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top