From 4080c6d2bced33e7ccecef5468bc724dd0f607da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=BB=C3=B3=C5=82tak?= Date: Thu, 16 May 2024 12:57:18 +0200 Subject: [PATCH 1/2] data-migration-scripts/v4.3.0-extractDimensions.php added --- .../v4.3.0-extractDimensions.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 data-migration-scripts/v4.3.0-extractDimensions.php diff --git a/data-migration-scripts/v4.3.0-extractDimensions.php b/data-migration-scripts/v4.3.0-extractDimensions.php new file mode 100644 index 0000000..faff6a7 --- /dev/null +++ b/data-migration-scripts/v4.3.0-extractDimensions.php @@ -0,0 +1,55 @@ +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(); + From 0a92425e1f21636b12493006f2ae6b66f3cc60ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20=C5=BB=C3=B3=C5=82tak?= Date: Thu, 16 May 2024 12:58:27 +0200 Subject: [PATCH 2/2] acdh-schema.owl: minor changes in rdfs:comment of the acdh:hasIiifManifest --- acdh-schema.owl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acdh-schema.owl b/acdh-schema.owl index f9807a3..238fd8b 100644 --- a/acdh-schema.owl +++ b/acdh-schema.owl @@ -1828,8 +1828,8 @@ https://www.iana.org/assignments/character-sets/character-sets.xhtml - 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. - 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's metadata, the URI of the dissemination service: https://id.acdh.oeaw.ac.at/dissemination/iiifmanifest. + 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. + 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's metadata, the URI of the dissemination service: https://id.acdh.oeaw.ac.at/dissemination/iiifmanifest. has custom iiif manifest Custom IIIF manifest Eigenes IIIF-Manifest