/usr/bin/ansel-exif-to-tags is in php-horde-ansel 3.0.5+debian0-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #!/usr/bin/php
<?php
/**
* Bare bones script to auto append an image's exif fields to it's tags.
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Michael J. Rubinsky <mrubinsk@horde.org>
*/
if (file_exists(__DIR__ . '/../../ansel/lib/Application.php')) {
$baseDir = __DIR__ . '/../';
} else {
require_once 'PEAR/Config.php';
$baseDir = PEAR_Config::singleton()
->get('horde_dir', null, 'pear.horde.org') . '/ansel/';
}
require_once $baseDir . 'lib/Application.php';
Horde_Registry::appInit('ansel', array('cli' => true, 'user_admin' => true));
/* Command line options */
$parser = new Horde_Argv_Parser(
array(
'usage' => '%prog [--options]',
'optionList' => array(
new Horde_Argv_Option(
'-f',
'--fields',
array(
'help' => 'A \':\' delimited list of exif fields to include',
'default' => 'Keywords',
)
)
)
)
);
// Show help and exit if no arguments were set.
list($opts, $args) = $parser->parseArgs();
// Get a tagger
$tagger = $injector->getInstance('Ansel_Tagger');
// Get the list of image ids that have exif data.
$sql = 'SELECT DISTINCT image_id from ansel_image_attributes;';
try {
$image_ids = $GLOBALS['ansel_db']->selectValues($sql);
} catch (Horde_Db_Exception $e) {
$cli->fatal($e->getMessage());
}
$fields = explode(':', $opts['fields']);
foreach ($image_ids as $image_id) {
try {
$image = $GLOBALS['injector']
->getInstance('Ansel_Storage')
->getImage($image_id);
$attributes = $image->getAttributes();
foreach ($attributes as $key => $value) {
if (in_array($key, $fields)) {
$image->setTags(array($value), false);
}
}
} catch (Ansel_Exception $e) {
$cli->fatal($e->getMessage());
}
$cli->message(sprintf(_("Extracted exif fields from %s"), $image->filename), 'cli.success');
}
$cli->message(_("Done"));
exit;
|