return empty text if image has no iptc data

This commit is contained in:
Uwe Steinmann 2023-01-05 09:35:13 +01:00
parent 735fe4235f
commit 292ade83e7

View File

@ -51,25 +51,24 @@ class SeedDMS_ConversionServiceImageToText extends SeedDMS_ConversionServiceBase
public function convert($infile, $target = null, $params = array()) { /* {{{ */
$start = microtime(true);
$imsize = getimagesize($infile, $moreinfo);
$txt = '';
if(!empty($moreinfo['APP13'])) {
$txt = '';
$iptcdata = iptcparse($moreinfo['APP13']);
foreach(['2#005', '2#015', '2#025', '2#105', '2#080', '2#115', '2#120'] as $key) {
if(isset($iptcdata[$key]))
$txt .= implode(' ', $iptcdata[$key])."\n";
}
$end = microtime(true);
if($this->logger) {
$this->logger->log('Conversion from '.$this->from.' to '.$this->to.' by extracting iptc took '.($end-$start).' sec.', PEAR_LOG_INFO);
}
if($target) {
file_put_contents($target, $txt);
return true;
} else {
return $txt;
}
}
return false;
if($this->logger) {
$this->logger->log('Conversion from '.$this->from.' to '.$this->to.' by extracting iptc took '.($end-$start).' sec.', PEAR_LOG_INFO);
}
if($target) {
file_put_contents($target, $txt);
return true;
} else {
return $txt;
}
} /* }}} */
}