Skip to content

Commit

Permalink
Merge branch 'v4.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
zozlak committed May 16, 2024
2 parents 6a2b942 + 0a92425 commit 1f63dc5
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
4 changes: 2 additions & 2 deletions acdh-schema.owl
Original file line number Diff line number Diff line change
Expand Up @@ -1828,8 +1828,8 @@ https://www.iana.org/assignments/character-sets/character-sets.xhtml</rdfs:comme
<rdfs:subPropertyOf rdf:resource="https://vocabs.acdh.oeaw.ac.at/schema#disseminationServices"/>
<rdfs:domain rdf:resource="https://vocabs.acdh.oeaw.ac.at/schema#Collection"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#anyURI"/>
<rdfs:comment xml:lang="de">Gibt das IIIF-Manifest (B) an, das für die Darstellung der Ressource (A) verwendet werden soll. Der Wert ist entweder die URL des zu verwendenden IIIF-Manifests (externe URLs sind möglich, wir empfehlen jedoch Ressourcen aus dem Repositorium) oder, wenn das IIIF-Manifest automatisch auf der Grundlage der Metadaten der Ressource generiert werden soll, die URI des Dissemination-Services: https://id.acdh.oeaw.ac.at/dissemination/iiifmanifest.</rdfs:comment>
<rdfs:comment xml:lang="en">Indicates the IIIF manifest (B) to be used for the presentation of the Resource (A). The value is either an URL of the IIIF manifest to be used (we recommend it to be another Resource in the repository but it can also be external) or, if the IIIF manifest should be generated automatically based on the Resource&apos;s metadata, the URI of the dissemination service: https://id.acdh.oeaw.ac.at/dissemination/iiifmanifest.</rdfs:comment>
<rdfs:comment xml:lang="de">Gibt das IIIF-Präsentation-Manifest (B) an, das für die Darstellung der Ressource (A) verwendet werden soll. Der Wert ist entweder die URL des zu verwendenden IIIF-Präsentation-Manifests (externe URLs sind möglich, wir empfehlen jedoch Ressourcen aus dem Repositorium) oder, wenn das IIIF-Manifest automatisch auf der Grundlage der Metadaten der Ressource generiert werden soll, die URI des Dissemination-Services: https://id.acdh.oeaw.ac.at/dissemination/iiifmanifest.</rdfs:comment>
<rdfs:comment xml:lang="en">Indicates the IIIF presentation manifest (B) to be used for the presentation of the Resource (A). The value is either an URL of the IIIF presentationmanifest to be used (we recommend it to be another Resource in the repository but it can also be external) or, if the IIIF manifest should be generated automatically based on the Resource&apos;s metadata, the URI of the dissemination service: https://id.acdh.oeaw.ac.at/dissemination/iiifmanifest.</rdfs:comment>
<rdfs:label xml:lang="en">has custom iiif manifest</rdfs:label>
<skos:altLabel xml:lang="en">Custom IIIF manifest</skos:altLabel>
<skos:altLabel xml:lang="de">Eigenes IIIF-Manifest</skos:altLabel>
Expand Down
55 changes: 55 additions & 0 deletions data-migration-scripts/v4.3.0-extractDimensions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
# Script creating acdh:hasPixelWidth and acdh:hasPixelHeight
# for data already existing in the repository
include '/home/www-data/vendor/autoload.php';

$pdo = new PDO('pgsql:');
$repo = acdhOeaw\arche\lib\RepoDb::factory('/home/www-data/config/yaml/config-repo.yaml');
$ph = $repo->getSchema()->imagePxHeight;
$pw = $repo->getSchema()->imagePxWidth;
$q = $pdo->prepare("
SELECT id
FROM metadata m
WHERE
property = 'https://vocabs.acdh.oeaw.ac.at/schema#hasFormat'
AND value LIKE 'image/%'
AND value NOT LIKE 'image/svg%'
AND value <> 'image/vnd.dxf'
AND NOT EXISTS (SELECT 1 FROM metadata WHERE id = m.id AND property = ?)
ORDER BY id
");
$q->execute([$ph]);
$images = $q->fetchAll(PDO::FETCH_COLUMN);
$pdo->beginTransaction();
$q = $pdo->prepare("INSERT INTO metadata (id, property, type, lang, value_n, value) VALUES (?, ?, 'http://www.w3.org/2001/XMLSchema#positiveInteger', '', ?, ?)");
$N = count($images);
foreach($images as $n => $id) {
if ($n % 100 === 0) {
echo ($n + 1) . " / $N\n";
$pdo->commit();
$pdo->beginTransaction();
}
$path = sprintf('/home/www-data/data/%02d/%02d/%d', $id % 100, floor($id / 100) % 100, $id);
$ret = getimagesize($path);
if (is_array($ret)) {
$h = $ret[1];
$w = $ret[0];
$q->execute([$id, $ph, $h, $h]);
$q->execute([$id, $pw, $w, $w]);
} else {
// getimagesize() files for gigabyte-size images but the exiftool manages
exec("exiftool '$path'", $output);
$w = array_filter($output, fn($x) => str_starts_with($x, 'Image Width'));
$w = (int) preg_replace('`^.*: *`', '', reset($w));
$h = array_filter($output, fn($x) => str_starts_with($x, 'Image Height'));
$h = (int) preg_replace('`^.*: *`', '', reset($h));
if ($w > 0 && $h > 0) {
$q->execute([$id, $ph, $h, $h]);
$q->execute([$id, $pw, $w, $w]);
} else {
echo "$path doesn't exist or is not an image $w $h\n";
}
}
}
$pdo->commit();

0 comments on commit 1f63dc5

Please sign in to comment.