January6
I have been impressed with the speed boost using Ruby and Rails to get everything done building out a simple backend admin website, but then I need to scale an image.
Ruby is fantastic, I had a sample script running on the command line with the ImageScience gem and it only took 6 lines of code to open and existing image and output it in two different sizes. I had all this running and assumed that doing this in rails would be a simple task…
Now I realise that the software I am using is beta and with an open source community not everything happens at the same time. I am sure these bugs will be fixed over time, so don’t apply these fixes unless you are using the same setup.
Current setup:
Ruby: 1.9.2p0 (rev 29036, Darwin X68_64)
Rails 3.0.3
RMagick 2.13.1
ImageMagick 6.6.6-30+q16
Trying to get Image Science gem and rails working together just doesn’t seem to work. There is some changes in one of the dependency gems that rails needs but causes Image Science to break. I tried some of the patches people have put online, but none of them seemed to fix my predicament. Fixing the bugs seemed beyond my current ruby/rails level of skill. I was hesitant about going with RMagick as I know ImageMagick has a tendency to be a complete pain to install, especially on web hosts.
I then went and installed ImageMagick and the RMagick gem as per the MacOSX port based instructions. This installed correctly but was causing a segmentation fault when calling read on Magick::Image.
To fix this, I needed to uninstall ImageMagick, and edit the way ImageMagick is built.
To uninstall:
sudo port uninstall ImageMagick
To edit the installation:
sudo port edit ImageMagic
This will bring up your editor, scroll to around line 100, and add the option –disable-openmp to configure.args. On my machine the section looked like this:
configure.args --enable-shared \
--enable-static \
--disable-ltdl-install \
--with-frozenpaths \
--without-openexr \
--disable-hdri \
--disable-openmp \
--with-dps \
--with-bzlib \
--with-fontconfig \
--with-gslib \
--with-jpeg \
--with-lcms \
--with-png \
--with-tiff \
--with-zlib \
--with-modules \
--with-xml \
--with-x \
--without-perl \
--without-fpx \
--without-jbig \
--without-jp2 \
--without-wmf \
--without-gvc \
--without-rsvg \
--without-lqr \
--with-gs-font-dir=${prefix}/share/fonts/urw-fonts
So apart from some bugs in my code everything was working fine… until I tried running this on my MacBookPro hoping to show the client in 45minutes. Checked out the repository, and everything was setup the same as above, except that the MacBookPro crashed WEBrick (test web server) with a error of: ‘Trace/BPT trap’ as the only output.
Not sure what the difference between the two machines was, but removing the ‘require ‘RMagick’ from the controller made the problem go away.
Having now spent a couple of hours running around in ruby configuration hell, I get back to the task of issuing a few commands on the command line and building out the website quickly and easily. I new all this easy development must be to good to be true. I just dread the installation when I have to deploy this to a linux host (next weeks problem).