Brother MFC-235C and phpSANE plus Scan-to-eMail etc.

Print This Post Print This Post

I had some challenge to get phpSANE to work with the flatbed scanner of my MFC-235C.

Although phpSANE should create a scanner ini file with the available settings of the scanner, this does not work out of the box with a simple install of phpSANE. To get the available settings of the sanner, scanimage -L is used. Using this manually reveals which SANE features are supported by the scanner:

Options specific to device `net:localhost:brother2:bus5;dev1':
    --mode Black & White|Gray[Error Diffusion]|True Gray|24bit Color [24bit Color]
        Select the scan mode
    --resolution 100|150|200|300|400|600|1200|2400|4800|9600dpi [200]
        Sets the resolution of the scanned image.
    --source FlatBed [FlatBed]
        Selects the scan source (such as a document-feeder).
    --brightness -50..50% (in steps of 1) [inactive]
        Controls the brightness of the acquired image.
    --contrast -50..50% (in steps of 1) [inactive]
        Controls the contrast of the acquired image.
    -l 0..215.9mm (in steps of 0.0999908) [0]
        Top-left x position of scan area.
    -t 0..355.6mm (in steps of 0.0999908) [0]
        Top-left y position of scan area.
    -x 0..215.9mm (in steps of 0.0999908) [215.88]
        Width of scan-area.
    -y 0..355.6mm (in steps of 0.0999908) [355.567]
        Height of scan-area.

But most of these values are not recognized by phpSANE. So I hardcoded some of the features directly in the phpSANE code.

Fixes and changes

  • Missing directories (output, scanners, tmp), incorrect permissions prevented phpSane to create a scanner ini for the scanner.
  • The Mode selection list was not filled as phpSane expects the special mode names Gray, Color and Lineart. I hard coded the mode_list and changed security.php to allow spaces, [, ] and &
  • The pnm output of the scanimage command for the brother is corrupted. I added a pipe into pamfixtrunc in the cmd used to generate files or preview (scan.php)
  • changed config.php to meet the scanners features. I.e. the lowest res supported is 100 and not 75.
  • although scanimage says the scanner supports brightness and contrast, phpSane was unable to read the correct values. I hardcoded brightness and contrast default, min and max values (0,-50, 50).

See my code at


I was unable to get the scripts provided to work with my Linux Debian installation, so I just coded some new scripts and replaced the original ones.

Here is my scan-to-email script ( using sendEmail package:

FILENAME="/tmp/$(date "+%Y-%m-%d_%H-%M-%S").jpg"
SCANCMD="/usr/bin/scanimage -d 'brother2:bus5;dev1' --mode 'True Gray' --resolution 150dpi -l 5mm -x 210mm -y 297mm | /usr/bin/pamfixtrunc | /usr/bin/pnmtojpeg > "$FILENAME
SENDEMAIL="/usr/bin/sendEmail -f '' -t "${SENDTO}" -u 'Scanned to email' -m 'Im Anhang das gescannte Dokument' -a "$FILENAME" -s '' -xu '' -xp 'yourepassword' -o tls=auto -o message-charset=utf-8"
eval ${SCANCMD}
exit 0

Fix corrupted pnm output of scanimage

Unfortunately the pnm out put of scanimage is corrupted with the MFC-235 bu can be fixed on-the-fly with the use of pamfixtrunc. This was used in my scan-to-email replacement and in my phpSANE setup.

Leave a Reply