1
|
/**
|
2
|
* Copyright (C) 2020 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.cdm.api.service.media;
|
10
|
|
11
|
import java.awt.Point;
|
12
|
import java.util.ArrayList;
|
13
|
import java.util.List;
|
14
|
|
15
|
/**
|
16
|
* Factory class to create default transformations
|
17
|
*
|
18
|
* @author a.kohlbecker
|
19
|
* @since Jul 15, 2020
|
20
|
*/
|
21
|
public class DefaultMediaTransformations {
|
22
|
|
23
|
/**
|
24
|
* Create default transformations for the diglilib server:
|
25
|
* <p>
|
26
|
* Links:
|
27
|
* <ul>
|
28
|
* <li>https://robcast.github.io/digilib/scaler-api.html</li>
|
29
|
* <li>https://robcast.github.io/digilib/iiif-api.html</li>
|
30
|
* </ul>
|
31
|
*
|
32
|
* @return
|
33
|
*/
|
34
|
static public List<MediaUriTransformation> digilib() {
|
35
|
|
36
|
List<MediaUriTransformation> defaultTransformations = new ArrayList<>();
|
37
|
|
38
|
/*
|
39
|
* dataPortalPreviewImage:
|
40
|
* image which fits the default preview image size which is
|
41
|
* for example used in the taxon general page, max extend of the resulting images is 400px
|
42
|
*/
|
43
|
String dataPortalPreviewImage = "digilib/Scaler/IIIF/$1!$2/full/!400,400/0/default.jpg";
|
44
|
Point dataPortalPreviewImageSize = new Point(400,400);
|
45
|
|
46
|
/*
|
47
|
* universalViewerThumbnail:
|
48
|
* crop to fit into a 200 x 147 preview box, the uvfix=1 parameter is used to
|
49
|
* prevent the universal viewer from corrupting the last query parameter. UV appends a parameter t with
|
50
|
* question mark character which causes problems for the URI query parser see https://dev.e-taxonomy.eu/redmine/issues/9132#note-8
|
51
|
*/
|
52
|
String universalViewerThumbnail = "digilib/Scaler/?fn=$1/$2&mo=crop&dw=200&dh=147&uvfix=1";
|
53
|
Point universalViewerThumbnailSize = new Point(200,147);
|
54
|
|
55
|
MediaUriTransformation tr1 = new MediaUriTransformation();
|
56
|
tr1.setPathQueryFragment(new SearchReplace("digilib/Scaler/IIIF/([^\\!]+)\\!([^\\/]+)(.*)", dataPortalPreviewImage));
|
57
|
tr1.setHost(new SearchReplace("pictures.bgbm.org", "pictures.bgbm.org")); // host part only used for matching, no replace!
|
58
|
tr1.setMimeType("image/jpeg");
|
59
|
tr1.setWidth(dataPortalPreviewImageSize.x);
|
60
|
tr1.setHeight(dataPortalPreviewImageSize.y);
|
61
|
|
62
|
MediaUriTransformation tr2 = new MediaUriTransformation();
|
63
|
tr2.setPathQueryFragment(new SearchReplace("digilib/Scaler/IIIF/([^\\!]+)\\!([^\\/]+)(.*)", universalViewerThumbnail));
|
64
|
tr2.setHost(new SearchReplace("pictures.bgbm.org", "pictures.bgbm.org")); // host part only used for matching, no replace!
|
65
|
tr2.setMimeType("image/jpeg");
|
66
|
tr2.setWidth(universalViewerThumbnailSize.x);
|
67
|
tr2.setHeight(universalViewerThumbnailSize.y);
|
68
|
|
69
|
MediaUriTransformation tr3 = new MediaUriTransformation();
|
70
|
tr3.setPathQueryFragment(new SearchReplace("digilib/Scaler/\\?fn=([^\\\\/]+)/(\\w+)(.*)", dataPortalPreviewImage));
|
71
|
tr3.setHost(new SearchReplace("pictures.bgbm.org", "pictures.bgbm.org")); // host part only used for matching, no replace!
|
72
|
tr3.setMimeType("image/jpeg");
|
73
|
tr3.setWidth(dataPortalPreviewImageSize.x);
|
74
|
tr3.setHeight(dataPortalPreviewImageSize.y);
|
75
|
|
76
|
MediaUriTransformation tr4 = new MediaUriTransformation();
|
77
|
tr4.setPathQueryFragment(new SearchReplace("digilib/Scaler/\\?fn=([^\\\\/]+)/(\\w+)(.*)", universalViewerThumbnail));
|
78
|
tr4.setHost(new SearchReplace("pictures.bgbm.org", "pictures.bgbm.org")); // host part only used for matching, no replace!
|
79
|
tr4.setMimeType("image/jpeg");
|
80
|
tr4.setWidth(universalViewerThumbnailSize.x);
|
81
|
tr4.setHeight(universalViewerThumbnailSize.y);
|
82
|
|
83
|
defaultTransformations.add(tr2);
|
84
|
defaultTransformations.add(tr1);
|
85
|
defaultTransformations.add(tr3);
|
86
|
defaultTransformations.add(tr4);
|
87
|
|
88
|
return defaultTransformations;
|
89
|
}
|
90
|
|
91
|
|
92
|
|
93
|
}
|