星期二, 7月 17, 2007

Installing RMagick on Ubuntu

Before install RMagick, we need to install ImageMagick and the delegate libraries used by ImageMagick.

Here are some recommended delegate libraries:

  • FreeType, Version 2.0 or above, to annotate with TrueType and Poscript Type 1 fonts.
  • libjpeg to read and write JPEG v1 format images.
  • The PNG library, to read and write PNG format images.
  • libwmf 0.2.5 or later, to read and write Windows Meta File (WMF) format images.
  • Ghostscript version 8.10, to read and write the PDF and PS document formats.
For the default Ubuntu 7.0.4 installation, I have to install FreeType v2 from a tarball. For the libjpeg, libpng, and libwmf, the runtime library are installed, so I just need to install the development library. Since I am too lazy, I just install those thru Synaptic Package Manager.

For the ghostscript, remember to install fonts into /usr/share/ghostscript; otherwise RMagick will complain during compilation.

Step 1: Install ImageMagick

Go to http://www.imagemagick.org and download the latest version of the software to a temporary directory.
tar xvzf ImageMagick.tar.gz
cd ImageMagick-X.Y.Z
Then configure ImageMagick
./configure --disable-static --with-modules --without-perl \
--without-magick-plus-plus --with-quantum-depth=8
Once you have configured ImageMagick the way you want it, enter these two commands:
make install
sudo make install

Step 2: Install RMagick

Issue the command

sudo gem install rmagick
You will see this output:
Bulk updating Gem source index for: http://gems.rubyforge.org
Building native extensions. This could take a while...
Successfully installed rmagick-1.15.7

Be patient. A lot of time will pass with no output from the gem command. The "Successfully installed" message does not mean that RMagick was successfully installed. The RMagick installation can encounter error conditions that gem can't detect. The following irb session is a better indicator of a successful install.

$ irb -rubygems -r RMagick
irb(main):001:0> puts Magick::Long_version
This is RMagick 1.15.7 ($Date: 2007/06/09 16:45:25 $) Copyright (C) 2007 by Timothy P. Hunter
Built with ImageMagick 6.3.5 07/17/07 Q8 http://www.imagemagick.org
Built for ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]
Web page: http://rmagick.rubyforge.org
Email: rmagick@rubyforge.org
=> nil

The RMagick HTML documentation is automatically installed at
/usr/local/share/RMagick/index.html.


Done!!!

星期五, 7月 13, 2007

Using GMail SMTP in ActionMailer

Rail's ActionMailer was simply the automatic choice, since I am building a rails app.

Turns out GMail supports only SSL SMTP mailing service, meaning if you cannot create a SSL connection to its SMTP server, you cannot send email through them. DHH writes about how to do so through installing msmtp here, but we developers just obviously love more choices.

Anatol Pomozov has developed a library called smtp_tls.rb . It allows us to use SMTP Server with TLS. Just follow the instruction in the original post, and then insert

require ‘smtp_tls’

under config/enviroment.rb

Finally, under config/enviroments/xxxxx.rb to specify Gmail settings

ActionMailer::Base.server_settings = {
:address => "smtp.gmail.com",
:port => "587",
:domain => "localhost.localdomain",
:authentication => :plain,
:user_name => "your Gmail account",
:password => "your Gmail Password"
}