Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Thursday, August 14, 2008

Hello world in Cocoa-Ruby

Here's a short video on how to do a "hello world" application in Cocoa-Ruby.




This was based on this japanese video I found on the web.

Wednesday, January 31, 2007

Image Size on Ruby

If you need to know the dimensions of an image file in ruby, for example because you want to set the "width" and "height" properties of an image on a web page, here's how to do it:

Start by getting libimage-size. If you're using Ubuntu you can fetch it using sudo apt-get install libimage-size-ruby.

You can now use the ImageSize class to fetch the width and height of your image. There are several ways of doing this, so here's one:

open(image_path) do |fh|
img_size = ImageSize.new(fh)
end
puts "Width: #{img_size.get_width} Height: #{img_size.get_height}"