Exemplo n.º 1
0
function jhove($file)
{
    $file = escapeshellcmd($file);
    $img_jhove = simplexml_load_string(exec_help("jhove '{$file}'", "/opt/jdk1.6.0_20/bin/java -jar /home/xrosecky/jhove/bin/JhoveApp.jar -h xml '{$file}' -c /home/xrosecky/jhove/conf/jhove.conf"));
    $xml = simplexml_load_string("<jhove></jhove>");
    $xml->addChild("format", $img_jhove->{"repInfo"}->{"format"});
    $xml->addChild("status", $img_jhove->{"repInfo"}->{"status"});
    return $xml;
}
Exemplo n.º 2
0
function validate($file)
{
    global $config;
    $fits = $config['fits'];
    $xml = simplexml_load_string("<validation></validation>");
    $img_fits = exec_help("{$fits} '{$file}'", "{$fits} -i '{$file}'");
    $img_fits = substr($img_fits, strpos($img_fits, "<?xml version"));
    $img_fits = simplexml_load_string(str_replace('xmlns=', 'ns=', $img_fits));
    $img_fits->registerXPathNamespace('fits', 'http://hul.harvard.edu/ois/xml/ns/fits/fits_output');
    // Identification
    $node = $xml->addChild("result");
    $node->addAttribute("type", "Identification");
    $format = $img_fits->xpath("//identification/identity[last()]/@format");
    if (strpos($format[0], "Usage") !== false) {
        $format = $img_fits->xpath("//identification/identity/@format");
    }
    $node->addChild("format", $format[0])->addAttribute("tool", "jhove");
    // Validation
    $node = $xml->addChild("result");
    $node->addAttribute("type", "Validation");
    $formed = $img_fits->xpath("//filestatus/well-formed/text()");
    $valid = $img_fits->xpath("//filestatus/valid/text()");
    $status_str = $formed[0] == "true" ? "Well formed" : "Bad formed";
    $status_str .= $valid[0] == "true" ? " and valid" : " and invalid";
    $node->addChild("status", $status_str)->addAttribute("tool", "jhove");
    // Characterization
    $node = $xml->addChild("result");
    $node->addAttribute("type", "Characterization");
    $width = $img_fits->xpath("//metadata/image/imageWidth");
    $height = $img_fits->xpath("//metadata/image/imageHeight");
    $node->addChild("width", (string) $width[0])->addAttribute("tool", "Jhove");
    $node->addChild("width", (string) $width[0])->addAttribute("tool", "exif");
    $node->addChild("height", (string) $height[0])->addAttribute("tool", "Jhove");
    $node->addChild("height", (string) $height[0])->addAttribute("tool", "exif");
    foreach ($config["extract"] as $key) {
        $values = $img_fits->xpath("//metadata/image/{$key}");
        if ($values) {
            foreach ($values as $value) {
                $new_node = $node->addChild($key, (string) $value);
                $new_node->addAttribute("tool", $value->attributes()->{'toolname'});
                $new_node->addAttribute("status", $value->attributes()->{'status'});
            }
        }
    }
    if ($format == "JP2 EXIF" || $format == "JPEG 2000 JP2" || $format == "JPEG 2000") {
        $result = jp2_properties($file);
        foreach ($result as $key => $value) {
            $node->addChild($key, (string) $value)->addAttribute("tool", "kdu_expand");
        }
    }
    $result = jp2_properties($file);
    foreach ($result as $key => $value) {
        $node->addChild($key, (string) $value)->addAttribute("tool", "kdu");
    }
    if ($format[0] == "DJVU" || $format[0] == "DJVU (multi-page)" || $format[0] == "jhove DJVU") {
        $djvu_dump = exec_help("djvudump '{$file}'", "djvudump '{$file}'");
        $node = $xml->addChild("djvu_dump", htmlentities($djvu_dump));
    }
    return $xml;
}