add getAdditionalParams(), getInfo(), width of image can be passed

This commit is contained in:
Uwe Steinmann 2021-10-08 12:12:37 +02:00
parent 306555cd45
commit 43c0f626ea

View File

@ -34,12 +34,22 @@ class SeedDMS_ConversionServiceImageToImage extends SeedDMS_ConversionServiceBas
$this->timeout = 5;
}
public function getInfo() {
return "Convert with imagick php functions";
}
public function getAdditionalParams() { /* {{{ */
return [
['name'=>'width', 'type'=>'number', 'description'=>'Width of converted image']
];
} /* }}} */
public function convert($infile, $target = null, $params = array()) {
$start = microtime(true);
$imagick = new Imagick();
if($imagick->readImage($infile)) {
if(!empty($params['width']))
$imagick->scaleImage((int) $params['width'], 0);
$imagick->scaleImage(min((int) $params['width'], $imagick->getImageWidth()), 0);
$end = microtime(true);
if($this->logger) {
$this->logger->log('Conversion from '.$this->from.' to '.$this->to.' with image service took '.($end-$start).' sec.', PEAR_LOG_INFO);