4

在 CentOS 安裝事務機驅動程式進行掃描

 2 years ago
source link: https://blog.darkthread.net/blog/scan-on-centos/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

在 CentOS 安裝事務機驅動程式進行掃描

calendar.svg 2021-12-03 11:27 PM comment.svg 2 eye.svg 866

小閃光抱怨家裡的 Fuji Xerox M225dw 印表機雖有網路列印及掃描功能,但掃描得開電腦跑 Fuji Xerox 軟體,不能直接傳到手機或平板上,很不方便。

查了一下,Xerox 有個 Xerox Workplace App 但鎖定對象是辦公室用的多功能事務機,透過掃 QR Code 或 NFC 感應加入印表機,不適用 M225 這類低階印表機。[2021-12-04 更新] 其實 FUJIFILM 有出 App,請見文末說明。

身為 Hacker,遇到這種狀況自然得做點什麼,想起我有迷你家用伺服器,若是能在上面安裝印表機驅動程式並執行掃描,我再寫個 ASP.NET Core 網站提供介面選取解析度、掃瞄模式,執行掃描後將圖檔傳回,不就是個雲端掃描服務?(謎之聲:雲你的頭啦)

但,CentOS 是伺服器能安裝印表機程式?還可以掃描?於是,我展開了奇幻冒險。

先查到這篇 StackExchange askubuntu 討論,有網友分享在 Ubuntu 安裝 Brother DCP-L2540DW driver 並使用 Simple Scan GUI 軟體成功掃描的經驗讓我士氣大振,至少,我確認從 Linux 呼叫 M225dw 掃描是可能的。

Ubuntu 安裝套件是 deb,CentOS 則是用 rpm,我試了 sudo yum install dpkg-devel dpkg-dev 安裝 dpkg,但 sudo rpm -ihv --nodeps brscan4-0.4.10-1.x86_64.rpm卡在 dpkg (subprocess): cannot set security execution context for maintainer script: Invalid argument 錯誤,無功而返。

後來我發現 Brother 官網居然也有驅動程式 rpm 套件,用 curl 下載curl https://download.brother.com/welcome/dlf105203/brscan4-0.4.10-1.x86_64.rpm --output brscan4-0.4.10-1.x86_64.rpm,再用sudo rpm -ihv --nodeps brscan4-0.4.10-1.x86_64.rpm即可安裝,但卡在找不到 /etc/sane.d/dll.conf 檔案。

研究了一下,原來 /etc/sane.d 是 Scanner Access Now Easy (SANE) 的設定目錄,要在 CentOS 使用 SANE,需先安裝 sane-backends rpm 套件 - sudo yum install sane-backends

sudo rpm -e brscan4-0.4.10-1.x86_64 移除再重新安裝,確認cat /etc/sane.d/dll.conf最後一行出現 brother4,代表安裝完成。

接著設定印表機名稱及 IP,sudo brsaneconfig4 -a name=FX-DocuPrint-M225-dw model=DCP-L2540DW ip=192.168.50.xxx,設定會寫入 /opt/brother/scanner/brscan4/brsanenetdevice4.cfg,至此,印表機的掃描器驅動就算安裝完成了。

CentOS 沒有 GUI 環境,有 Command Line 的掃描指令嗎?有! scanimage

scanimage 包含在 sane-backends 套件裡,用 scanimage -L 會列出可用的印表裝置,scanimage -A 則會列出印表機的可用掃描參數:

有幾個重要參數,mode 決定黑色灰階彩色、resolution 是解析度 DPI、source 是來源(玻璃板還是進紙器)、brightness 亮度、contrast 對比,掃瞄座標 left、top、寬度高度等等。

CentOS 上的 scanimage 工具版本 format 只支援 SANE 專屬的 pnm 跟 tiff 兩種格式,tiff 較普遍。用以下參數試掃吉他譜:

scanimage -v -p --format tiff -d 'brother4:net1;dev0' -x 210 -y 180 --source FlatBed --resolution 150 > tab.tiff

【更新】讀者 smfself 分享,其實 FUJIFILM 有出 App - Print Utility V3,其中包含掃描下載到手機或平板的功能。

依據坎寧漢定律,從 Internet 獲得正確答案的最佳方式不是發問,而是貼一篇錯的答案,分享土砲解法也有異曲同工之妙。
我也來個「黑暗土砲定律」好了:當遍尋不著現成解決方案,那就研究土砲方法分享給大家指教,熱心網友會現身指引你一盞明燈;若不幸沒有,需求有被滿足,過程會學到東西,你的分享還可能成為別人的明燈,橫豎都不吃虧,Just Do It!

感謝 smfself,Internet 萬歲!

and has 2 comments

Comments

Post a comment

Comment
Name Captcha 71 - 55 =

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK