Use PHPExiftool service provider

This commit is contained in:
Romain Neutron
2013-01-21 20:44:27 +01:00
parent daceabf8e8
commit 73da820b86
2 changed files with 5 additions and 11 deletions

View File

@@ -45,12 +45,9 @@ class Tools implements ControllerProviderInterface
$record = $records->first(); $record = $records->first();
if (!$record->is_grouping()) { if (!$record->is_grouping()) {
try { try {
$reader = new \PHPExiftool\Reader(); $metadatas = $app['exiftool.reader']
$metadatas = $reader
->files($record->get_subdef('document')->get_pathfile()) ->files($record->get_subdef('document')->get_pathfile())
->first()->getMetadatas(); ->first()->getMetadatas();
unset($reader);
} catch (\PHPExiftool\Exception\Exception $e) { } catch (\PHPExiftool\Exception\Exception $e) {
} catch (\Exception_Media_SubdefNotFound $e) { } catch (\Exception_Media_SubdefNotFound $e) {

View File

@@ -201,6 +201,8 @@ class task_period_writemeta extends task_databoxAbstract
protected function retrieveSbasContent(databox $databox) protected function retrieveSbasContent(databox $databox)
{ {
$this->dependencyContainer['exiftool.writer']->setModule(Writer::MODULE_MWG, true);
$connbas = $databox->get_connection(); $connbas = $databox->get_connection();
$subdefgroups = $databox->get_subdef_structure(); $subdefgroups = $databox->get_subdef_structure();
$metasubdefs = array(); $metasubdefs = array();
@@ -297,15 +299,12 @@ class task_period_writemeta extends task_databoxAbstract
); );
} }
$writer = new Writer();
$writer->setModule(Writer::MODULE_MWG, true);
foreach ($tsub as $name => $file) { foreach ($tsub as $name => $file) {
$writer->erase($name != 'document' || $this->clear_doc); $this->dependencyContainer['exiftool.writer']->erase($name != 'document' || $this->clear_doc);
try { try {
$writer->write($file, $metadatas); $this->dependencyContainer['exiftool.writer']->write($file, $metadatas);
$this->log(sprintf('Success writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)', $this->sbas_id, $record_id, $name)); $this->log(sprintf('Success writing meta for sbas_id=%1$d - record_id=%2$d (%3$s)', $this->sbas_id, $record_id, $name));
} catch (\PHPExiftool\Exception\Exception $e) { } catch (\PHPExiftool\Exception\Exception $e) {
@@ -313,8 +312,6 @@ class task_period_writemeta extends task_databoxAbstract
} }
} }
$writer = $metadatas = null;
return $this; return $this;
} }