Fight Image Spam With FuzzyOCR And SpamAssassin On Debian/Ubuntu

Version 1.0
Author: Falko Timme
Last edited 02/12/2007

This tutorial describes how to scan emails for image spam with FuzzyOCR. FuzzyOCR is a plugin for SpamAssassin which is aimed at unsolicited bulk mail containing images as the main content carrier. Using different methods, it analyzes the content and properties of images to distinguish between normal mails (ham) and spam mails. FuzzyOCR tries to keep the system load low by scanning only mails that have not already been categorized as spam by SpamAssassin, thus avoiding unnecessary work.

I do not issue any guarantee that this will work for you!


1 Preliminary Note

In this article I will use Debian Etch for the base system. The steps to install FuzzyOCR should be the same for Ubuntu systems.

I assume that SpamAssassin is already installed and working, with /etc/mail/spamassassin/ as its main configuration directory. If your directory is different (e.g. if you have ISPConfig installed, the directory is /home/admispconfig/ispconfig/tools/spamassassin/etc/mail/spamassassin/), this is no problem. I will annotate where to change what.

Please make sure that your SpamAssassin version works with FuzzyOCR. For example, the FuzzyOCR version I'm going to install here (fuzzyocr-3.5.1-devel.tar.gz) requires SpamAssassin 3.1.4 or newer.


2 Install The Prerequisites For FuzzyOCR

FuzzyOCR has some prerequisites like ocrad and gocr that we can install like this:

apt-get install netpbm gifsicle libungif-bin gocr ocrad libstring-approx-perl libmldbm-sync-perl imagemagick tesseract-ocr


3 Install FuzzyOCR

Next we download and install the latest FuzzyOCR devel version from We download the devel version instead of the stable version because the FuzzyOCR developers say:

"The current recommendation is the development version because the stable version lacks features and is very old."

cd /usr/src/

Then we unpack FuzzyOCR and move all FuzzyOcr* files and the FuzzyOcr directory (they are all in the FuzzyOcr-3.5.1/ directory) to /etc/mail/spamassassin:

tar xvfz fuzzyocr-3.5.1-devel.tar.gz
cd FuzzyOcr-3.5.1/
mv FuzzyOcr* /etc/mail/spamassassin/

If your SpamAssassin directory is different, e.g. /home/admispconfig/ispconfig/tools/spamassassin/etc/mail/spamassassin/, then the last command should be replaced with

mv FuzzyOcr* /home/admispconfig/ispconfig/tools/spamassassin/etc/mail/spamassassin/

Don't delete the /usr/src/FuzzyOcr-3.5.1/ directory yet, there's a directory with sample image spam emails in there (samples/) that we need later on to test if FuzzyOCR is working as expected.

So FuzzyOCR is now installed, now we need to configure it.

Share this page:

3 Comment(s)

Add comment


From: at: 2007-02-13 16:02:11

Thanks for this nice tutorial,

I am looking for additionnal informations about fuzzyOCR  efficency. Spam image is changing a lot, spammers are regulary adding noise to pictures in order to bypass OCR . Good news is ressources needs which seems to be correct.


-Is fuzzyOCR updated regulary.

-What are your spam statistics with fuzzyOCR install on your mail gateway ?. Is it a real added value on your mail gateway ?.





From: at: 2007-02-16 10:11:05
From: Anonymous at: 2009-05-25 19:14:47

Hello, Thanks for document. Verry good.

I used you document step, but I dont block imaj spam.
I following error message :

lnx:/etc/mail/spamassassin/FuzzyOcr-3.5.1/samples# spamassassin --debug FuzzyOcr < /etc/mail/spamassassin/FuzzyOcr-3.5.1/samples/resimspam.eml > /dev/null
[12257] warn: plugin: failed to parse plugin /etc/mail/spamassassin/ Can't locate Image/ in @INC (@INC contains: lib /usr/share/perl/5.8.8 /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl) at /etc/mail/spamassassin/ line 100.
[12257] warn: BEGIN failed--compilation aborted at /etc/mail/spamassassin/ line 100.
[12257] warn: Compilation failed in require at /usr/share/perl/5.8.8/Mail/SpamAssassin/ line 107.
Subroutine FuzzyOcr::O_CREAT redefined at /usr/share/perl/5.8/ line 65.
 at /usr/lib/perl/5.8/ line 19
Subroutine FuzzyOcr::O_EXCL redefined at /usr/share/perl/5.8/ line 65.
 at /usr/lib/perl/5.8/ line 19
Subroutine FuzzyOcr::O_RDWR redefined at /usr/share/perl/5.8/ line 65.
 at /usr/lib/perl/5.8/ line 19
[12257] dbg: FuzzyOcr: focr_bin_helper: 'pnmnorm,pnminvert,convert,ppmtopgm,tesseract'
[12257] info: FuzzyOcr: Adding <5> new helper apps
[12257] info: FuzzyOcr: Starting preprocessor parser for file "/etc/mail/spamassassin/FuzzyOcr.preps"...