supermikenews

My views on software, programming, Linux, the Internet, government, taxation, working, and life.

Tuesday, October 24, 2006

Making Imaging Apps in Linux PHP


I found after some research that if you know a little PHP, it's super-easy to make your own imaging apps in PHP on Linux.

But wait! Before you read "linux" and get turned off because your users use Windows, do not despair. You can use Ubuntu Linux or your favorite Linux as your scan station, but then the web app can serve up the docs for viewing and printing through other workstations running Windows and either IE or Firefox.

In Ubuntu Linux, you'll find a 'scanimage' command-line command is readily available to you which interfaces with your USB scanner. Also in Ubuntu Linux, if you temporarily turn on universe mode in your /etc/apt/sources.list file and do an apt-get update, then 'apt-cache search plugin | grep -i plugin' and 'apt-cache search tiff | grep -i tiff', you can then find 3 things extra that will be useful to you: mozilla-acroread, acroread-plugins, and libtiff-tools. You can install them with 'apt-get install x' style syntax.

PHP supports shelling out to command-line in the background with the $result = `$sCmd`; syntax and from that you can shell out to run the scanimage command. This can be told a set of parameters to read in the image from the USB scanner and convert it to a TIFF image. Great -- you have a TIFF file, but it doesn't display well in IE without a plugin and IE will want to load it with Kodak Image Viewer on Windows XP, which loads outside the browser. The ideal thing would be to convert that TIFF to a PDF, and there are a few reasons for this. For one, Linux makes very efficient PDFs that are more compressed than PDFs generated by even Adobe itself. Adobe's tools add a lot of bloat for extra features that you might not use in ordinary scanned forms you pull from your scanner. Therefore, TIFF to PDF conversion and storage is going to consume less disk space on Linux than straight TIFF image storage would, but it's your call.

If you choose to convert to PDF and then store the TIFF, you first run it through scanimage, generate the TIFF, and then use a tool called tiff2pdf to convert it (very fast, I might add!) to PDF. Then, store the PDF and delete the TIFF file. Last, display the PDF in the browser.

If you choose to store the TIFF images but provide viewing of the TIFF as a PDF on the fly, have PHP run it through tiff2pdf on the fly and then display the PDF in the browser.

With the Adobe Acrobat plugin, you can then view the PDF with options to flip through pages, magnify, rotate, email, save, and print the document. If Reader is installed, you can set it to open separately from the browser. If the plugin is installed, you can set it to open the document inline inside the browser.

Still, if you absolutely want to display the TIFF image, look around on the web and you'll find products that are free that work in IE or Firefox to display these in about the same format as Adobe Reader offers.

Linux also has a way to push the files easily to Windows with something called 'smbfs'. If this is installed in your brand of Linux, you can mount a remote Windows share locally on your Linux hard drive with the 'mount -t smbfs' command (do 'man mount' or read docs on the web for how to do this). Then, you can copy the files to this Windows server just as easy as you copying them from one directory to another on Linux with the 'cp' command.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home