Was schon läuft:
<?php
class AllScanners {
public $arScanners = false;
function __construct() {
if ( false === $this -> arScanners ) {
$this -> detectScanners();
}
}
function detectScanners() {
$returns = "
All options specific to device `BrotherADS2200:libusb:001:007':
-l 0..165.1mm [0]
Top-left x position of scan area.
-t 0..304.8mm [0]
Top-left y position of scan area.
-x 50.8..215.9mm [215.9]
Width of scan-area.
-y 50.8..355.6mm [355.6]
Height of scan-area.
--resolution 100|150|200|300|400|600dpi [200]
Sets the resolution of the scanned image.
--mode Black & White|Gray|24 bit Color [Black & White]
Selects the scan mode (e.g., lineart, monochrome, or color).
--source Automatic Document Feeder(left aligned)|Automatic Document Feeder(left aligned,Duplex) [Automatic Document Feeder(left aligned)]
Selects the scan source (such as a document-feeder).
";
$lines = explode ( "\n", $returns );
$scannerID = -1;
foreach ( $lines as $line ) {
$line = trim ( $line );
if ( "" !== $line ) {
if ( 0 === strpos( $line, "All options specific to device" ) ) {
$scannerID ++;
$beginName = strpos( $line, '`' ) + 1 ;
$endName = strpos( $line, ':' ) - $beginName;
$arScanners[$scannerID] = array();
$arScanners[$scannerID]['ScannerName'] = substr ( $line, $beginName, $endName );
$optionCounter = -1;
} elseif ( 0 === strpos( $line, '-') ) {
$optionCounter ++;
list( $option, $rest ) = explode ( ' ', $line, 2 );
$optionName = str_replace('-', '', $option ) ;
$arScanners[$scannerID]['options'][$optionCounter]['option'] = $option;
$arScanners[$scannerID]['options'][$optionCounter]['optionName'] = $optionName;
} else {
if ( strpos ( $rest, '..' ) ) {
$arScanners[$scannerID]['options'][$optionCounter]['Type'] = 'FromTo';
list( $values, $rest2 ) = explode ( ' ', $rest );
List ($strMin, $strMax ) = explode ('..', $values );
$arScanners[$scannerID]['options'][$optionCounter]['minValue'] = (float)$strMin;
$arScanners[$scannerID]['options'][$optionCounter]['maxValue'] = (float)$strMax;
$arScanners[$scannerID]['options'][$optionCounter]['Unit'] = str_replace( (string)(float)$strMax, '', $strMax );
$arScanners[$scannerID]['options'][$optionCounter]['defaultValue'] = substr( $rest2, 1, -1 );
} elseif ( strpos ( $rest, '|' ) ) {
$arScanners[$scannerID]['options'][$optionCounter]['Type'] = 'OneOf';
list( $values, $rest2 ) = explode ( '[', $rest );
$values = explode( '|', trim( $values ) );
$arScanners[$scannerID]['options'][$optionCounter]['defaultValue'] = substr( $rest2, 0, -1 );
$strLastValue = array_pop( $values );
$floatLastValue = (float)$strLastValue;
if ( $floatLastValue and false === strpos($strLastValue, ' ' ) ) {
$values[] = $floatLastValue;
$arScanners[$scannerID]['options'][$optionCounter]['Unit'] = str_replace( (string)$floatLastValue , '', $strLastValue );
} else {
$values[] = $strLastValue;
}
$arScanners[$scannerID]['options'][$optionCounter]['values'] = $values;
}
$arScanners[$scannerID]['options'][$optionCounter]['Description'] = $line;
}
}
}
$this -> arScanners = $arScanners;
}
function showScanners () {
print '<pre>';
print_r( $this -> arScanners );
}
}
$scanner = new AllScanners();
$scanner->showScanners();
Ausgaben:
Array
(
[0] => Array
(
[ScannerName] => BrotherADS2200
[options] => Array
(
[0] => Array
(
[option] => -l
[optionName] => l
[Type] => FromTo
[minValue] => 0
[maxValue] => 165.1
[Unit] => mm
[defaultValue] => 0
[Description] => Top-left x position of scan area.
)
[1] => Array
(
[option] => -t
[optionName] => t
[Type] => FromTo
[minValue] => 0
[maxValue] => 304.8
[Unit] => mm
[defaultValue] => 0
[Description] => Top-left y position of scan area.
)
[2] => Array
(
[option] => -x
[optionName] => x
[Type] => FromTo
[minValue] => 50.8
[maxValue] => 215.9
[Unit] => mm
[defaultValue] => 215.9
[Description] => Width of scan-area.
)
[3] => Array
(
[option] => -y
[optionName] => y
[Type] => FromTo
[minValue] => 50.8
[maxValue] => 355.6
[Unit] => mm
[defaultValue] => 355.6
[Description] => Height of scan-area.
)
[4] => Array
(
[option] => --resolution
[optionName] => resolution
[Type] => OneOf
[defaultValue] => 200
[Unit] => dpi
[values] => Array
(
[0] => 100
[1] => 150
[2] => 200
[3] => 300
[4] => 400
[5] => 600
)
[Description] => Sets the resolution of the scanned image.
)
[5] => Array
(
[option] => --mode
[optionName] => mode
[Type] => OneOf
[defaultValue] => Black & White
[values] => Array
(
[0] => Black & White
[1] => Gray
[2] => 24 bit Color
)
[Description] => Selects the scan mode (e.g., lineart, monochrome, or color).
)
[6] => Array
(
[option] => --source
[optionName] => source
[Type] => OneOf
[defaultValue] => Automatic Document Feeder(left aligned)
[values] => Array
(
[0] => Automatic Document Feeder(left aligned)
[1] => Automatic Document Feeder(left aligned,Duplex)
)
[Description] => Selects the scan source (such as a document-feeder).
)
)
)
)
Wie ich das Linux dazu bekomme, dem www-run das Scannen zu erlauben weiß ich auch schon. Ein einfaches Scan-Script (mit fixen Optionen) läuft ebenfalls bereits.