Entries Tagged 'ImageMagick' ↓

Rails is Bailing out in RMagick…

Maybe I’m a fool for putting my RMagick into a Rails controller and not a model. We’ll see, later. After I adjust things a bit and try the model approach.

Here the code as a stand alone script:

# RMagick Test
require 'rubygems'
require 'rmagick'
include Magick

puts "Enter the name of the file to thumb:"
image_to_alter = gets.chomp
img = Image.read(image_to_alter)[0]

thumbnail_height = 100
thumbnail_width = 100

geometry_obj = Geometry.new(thumbnail_width, thumbnail_height, nil, nil, '!')
chg_geom_img = img.change_geometry(geometry_obj) {|cols, rows, image| image.resize(cols, rows)}
chg_geom_img_name = 'thumbnail_' + image_to_alter#@basename_of_f

chg_geom_img.write(chg_geom_img_name)

Here is the original image:
buddagold.jpg

Here is the image after resizing with my Ruby script:

thumbnail_buddagold.jpg

Here is the version that was resized using almost the identical code, from within a Rails app:
rails_thumbnail_buddagold.jpg

Screwy, huh?
Any tips/advice very welcome!

Waylaid by RMagick Woe

My Rails app adventures have ground to halt finally. The app itself is still viable, though filled with code that needs refactoring for sure. But the image processing is screwed for now. At least on OS X. I’m going to have to move on to other aspects of the app for now.
Simply resizing images in RMagick results in stuff like this far too often to be reliable for now.
bad image
It’s not drastic in this example, but it’s not acceptable either, the grey at the bottom shouldn’t be there at all. It’s not in the original image. Resizing an image to a smaller size certainly shouldn’t introduce this stuff.

Any help is welcome…