Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for upscaling IIIF V3 #334

Merged
merged 34 commits into from
Oct 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
aa882e1
Squashed commit of the following:
lrosenth Jul 1, 2020
af6990d
fixing issue #287
lrosenth Jul 1, 2020
6193427
Bugfix in lua: binding of values in prepared SQL
lrosenth Jul 1, 2020
faf7103
Bug fixes of issues
lrosenth Jul 2, 2020
a18987a
more fixes
lrosenth Jul 2, 2020
336a2a9
Squashed commit of the following:
lrosenth Jul 2, 2020
b025ab0
Merge branch 'develop' into fix/issues-fixer
subotic Jul 2, 2020
4ed55e8
Missing files added
lrosenth Jul 3, 2020
9a18b82
Merge branch 'fix/issues-fixer' of github.com:dasch-swiss/sipi into i…
lrosenth Jul 3, 2020
30f91c3
Missing filew…
lrosenth Jul 3, 2020
7aba93c
test: add missing file
subotic Jul 3, 2020
55081d7
test: trying to fix
subotic Jul 3, 2020
385bf22
test: reverting wrong fix
subotic Jul 3, 2020
2613226
Added XML content to XMP file
lrosenth Jul 4, 2020
334ebda
Testing now removes all files created at the end of testing
lrosenth Jul 5, 2020
1055545
Bugfix in SipiSize and Cache
lrosenth Jul 7, 2020
3d618ac
removed debugging output (commented out)
lrosenth Jul 7, 2020
df6fd0d
refactoring of core
lrosenth Jul 16, 2020
df5066e
Merge branch 'develop' into fix/issues-fixer
lrosenth Jul 16, 2020
f028306
Further reorganization
lrosenth Jul 20, 2020
7063a19
More IIIF conformance
lrosenth Aug 2, 2020
6628256
...
lrosenth Aug 2, 2020
959bfab
A lot of documentation and some small fixes
lrosenth Aug 3, 2020
b2fe025
Documentation
lrosenth Aug 3, 2020
41af71e
Docu and small fixes for stability
lrosenth Aug 4, 2020
b4ef618
Some fixes for cache information in lua
lrosenth Aug 4, 2020
caea0bb
Docu update and fixes
lrosenth Aug 7, 2020
7d786c1
better error messages
lrosenth Aug 7, 2020
9a2d950
Merge branch 'develop' into fix/issues-fixer
lrosenth Sep 23, 2020
81ec049
CSV mimteype fix
lrosenth Sep 28, 2020
42e3b65
Update of e2e tests to reflect mimetype change for csv
lrosenth Sep 28, 2020
59be936
Bugfix which made SIPI crash if upscaling an image
lrosenth Oct 25, 2020
1c9dd59
Squashed commit of the following:
lrosenth Oct 25, 2020
8f7f62c
Added tests for upscaling
lrosenth Oct 26, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ include(CheckIncludeFiles)

project(sipi)

string(TIMESTAMP SIPIDATE "%Y-%m-%d %H:%M")
set(SIPI_RELEASE "Sipi Version v2.0.0-SNAPSHOT (build ${SIPIDATE})")

# ------------------------------------------------------------------------------
# Set our path variables
# the build folder will hold all downloaded, built, and installed files
Expand Down Expand Up @@ -251,19 +248,31 @@ if(DOXYGEN_FOUND)
)
endif(DOXYGEN_FOUND)

# get current date and time
string(TIMESTAMP BUILD_TIMESTAMP "%Y-%m-%d %H:%M")
MESSAGE( STATUS "Build timestamp: ${BUILD_TIMESTAMP}" )

# get version from git
IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)
FIND_PACKAGE(Git)
IF(GIT_FOUND)
EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE "SIPI_BUILD_VERSION"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
MESSAGE( STATUS "Git version: ${SIPI_BUILD_VERSION}" )
COMMAND ${GIT_EXECUTABLE} describe --tag --dirty --abbrev=7
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE "BUILD_SCM_TAG"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
MESSAGE( STATUS "Build SCM tag: ${BUILD_SCM_TAG}" )
EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE "BUILD_SCM_REVISION"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
MESSAGE( STATUS "Build SCM revision: ${BUILD_SCM_REVISION}" )
ELSE(GIT_FOUND)
SET(SIPI_BUILD_VERSION 0)
SET(BUILD_SCM_REVISION 0)
SET(BUILD_SCM_TAG 0)
ENDIF(GIT_FOUND)
ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git)

Expand Down
7 changes: 4 additions & 3 deletions config/sipi.config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ sipi = {
-- The cache will be purged if either the maximal size or maximal number
-- of files is reached
--
cachesize = '200M',
cachesize = '20M',

--
-- maximal number of files to be cached
-- The cache will be purged if either the maximal size or maximal number
-- of files is reached
--
cache_nfiles = 250,
cache_nfiles = 8,

--
-- if the cache becomes full, the given percentage of file space is marked for reuse
Expand Down Expand Up @@ -196,7 +196,8 @@ sipi = {
--
-- loglevel, one of "EMERGENCY", "ALERT", "CRITICAL", "ERROR", "WARNING", "NOTICE", "INFORMATIONAL", "DEBUG"
--
loglevel = "ERROR"
loglevel = "DEBUG"
--loglevel = "ERROR"
}

admin = {
Expand Down
6 changes: 4 additions & 2 deletions include/SipiConfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
#cmakedefine HAVE_MALLOC_H 1
#cmakedefine HAVE_ST_ATIMESPEC

#define SIPI_BUILD_DATE "${SIPI_RELEASE}"
#define SIPI_BUILD_VERSION "Sipi Source Git-Version: ${SIPI_BUILD_VERSION}"
#define BUILD_TIMESTAMP "BUILD_TIMESTAMP: ${BUILD_TIMESTAMP}"
#define BUILD_SCM_TAG "BUILD_SCM_TAG: ${BUILD_SCM_TAG}"
#define BUILD_SCM_REVISION "BUILD_SCM_REVISION: ${BUILD_SCM_REVISION}"


#endif
3 changes: 1 addition & 2 deletions shttps/Parsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ namespace shttps {
{"mp2", {"audio/x-mpeg"}},
{"wrl", {"model/vrml", "x-world/x-vrml"}},
{"ics", {"text/calendar"}},
{"csv", {"text/comma-separated-values", "text/plain", "application/vnd.ms-excel",
"application/csv", "text/csv"}},
{"csv", {"text/csv", "application/csv", "text/plain", "application/vnd.ms-excel", "text/comma-separated-values"}},
{"tsv", {"text/tab-separated-values", "text/plain", "text/x-csv"}},
{"txt", {"text/plain"}},
{"rtx", {"text/richtext"}},
Expand Down
11 changes: 7 additions & 4 deletions src/SipiHttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ namespace Sipi {
json_object_set_new(root, "protocol", json_string("http://iiif.io/api/image"));
json_object_set_new(root, "profile", json_string("level2"));
} else {
json_object_set_new(root, "mimeType", json_string(actual_mimetype.c_str()));
json_object_set_new(root, "internalMimeType", json_string(actual_mimetype.c_str()));

struct stat fstatbuf;
if (stat(access["infile"].c_str(), &fstatbuf) != 0) {
Expand Down Expand Up @@ -741,7 +741,7 @@ namespace Sipi {
json_decref(root);
}
else {
json_object_set_new(root, "mimeType", json_string(actual_mimetype.c_str()));
json_object_set_new(root, "internalMimeType", json_string(actual_mimetype.c_str()));

struct stat fstatbuf;
if (stat(infile.c_str(), &fstatbuf) != 0) {
Expand Down Expand Up @@ -939,12 +939,12 @@ namespace Sipi {
continue;
}

parts.push_back(uri.substr(old_pos, pos - old_pos - 1));
parts.push_back(shttps::urldecode(uri.substr(old_pos, pos - old_pos - 1)));
old_pos = pos;
}

if (old_pos != uri.length()) {
parts.push_back(uri.substr(old_pos, std::string::npos));
parts.push_back(shttps::urldecode(uri.substr(old_pos, std::string::npos)));
}

if (parts.size() < 1) {
Expand Down Expand Up @@ -1528,6 +1528,9 @@ namespace Sipi {
} catch (const SipiImageError &err) {
send_error(conn_obj, Connection::INTERNAL_SERVER_ERROR, err.to_string());
return;
} catch (const SipiSizeError &err) {
send_error(conn_obj, Connection::BAD_REQUEST, err.to_string());
return;
}

//
Expand Down
7 changes: 1 addition & 6 deletions src/iiifparser/SipiSize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ namespace Sipi {
} else {
h = static_cast<size_t>(ceilf(static_cast<float>(img_h * nx) / img_w_float));
}

if (!upscaling && (w > img_w || h > img_h)) {
throw SipiSizeError(400, "Upscaling not allowed!");
}
Expand Down Expand Up @@ -422,12 +423,6 @@ namespace Sipi {
}
}

if (w > img_w || h > img_h) {
upscaling = true;
} else {
upscaling = false;
}

w_p = w;
h_p = h;

Expand Down
10 changes: 6 additions & 4 deletions src/sipi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,9 @@ int main(int argc, char *argv[]) {
//

try {
std::cout << std::endl << SIPI_BUILD_DATE << std::endl;
std::cout << SIPI_BUILD_VERSION << std::endl;
std::cout << std::endl << BUILD_TIMESTAMP << std::endl;
std::cout << BUILD_SCM_TAG << std::endl;
std::cout << BUILD_SCM_REVISION << std::endl;

Sipi::SipiConf sipiConf;
bool config_loaded = false;
Expand Down Expand Up @@ -1136,8 +1137,9 @@ int main(int argc, char *argv[]) {
sipiConf.getLoglevel());

int old_ll = setlogmask(LOG_MASK(LOG_INFO));
syslog(LOG_INFO, SIPI_BUILD_DATE);
syslog(LOG_INFO, SIPI_BUILD_VERSION);
syslog(LOG_INFO, BUILD_TIMESTAMP);
syslog(LOG_INFO, BUILD_SCM_TAG);
syslog(LOG_INFO, BUILD_SCM_REVISION);
setlogmask(old_ll);

# ifdef SHTTPS_ENABLE_SSL
Expand Down
Binary file added test/_test_data/images/unit/lena512_upscaled.tif
Binary file not shown.
10 changes: 7 additions & 3 deletions test/e2e/test_02_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_mimeconsistency(self, manager):
},
{
"filepath": "knora/csv_test.csv",
"mimetype": "text/comma-separated-values",
"mimetype": "text/csv",
"expected_result": {
"consistency": True,
"origname": "csv_test.csv"
Expand Down Expand Up @@ -228,11 +228,11 @@ def test_knora_info_validation(self, manager):
}
},{
"filepath": "unit/test.csv",
"mimetype": "text/comma-separated-values",
"mimetype": "text/csv",
"expected_result": {
"@context": "http://sipi.io/api/file/3/context.json",
"id": "http://127.0.0.1:1024/unit/",
"mimeType": "text/comma-separated-values",
"internalMimeType": "text/csv",
"fileSize": 39697
}
}
Expand Down Expand Up @@ -470,6 +470,10 @@ def test_pdf_page_server(self, manager):
"""Test serving a PDF page as TIFF"""
manager.compare_server_images("/unit/CV+Pub_LukasRosenthaler.pdf@3/full/pct:25/0/default.jpg", manager.data_dir_path("unit/CV+Pub_LukasRosenthaler_p3.jpg"))

def test_upscaling_server(self, manager):
"""Test upscaling of an image"""
manager.compare_server_images("/unit/lena512.jp2/full/^1000,/0/default.tif", manager.data_dir_path("unit/lena512_upscaled.tif"))

def test_concurrency(self, manager):
"""handle many concurrent requests for different URLs (this may take a while, please be patient)"""

Expand Down
6 changes: 3 additions & 3 deletions test/unit/configuration/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ TEST(Configuration, LoadConfigurationFile)
EXPECT_EQ(sipiConf.getSubdirExcludes().size(), 2);
EXPECT_EQ(sipiConf.getInitScript(), "./config/sipi.init.lua");
EXPECT_EQ(sipiConf.getCacheDir(), "./cache");
EXPECT_EQ(sipiConf.getCacheSize(), 200 * 1024 * 1024);
EXPECT_EQ(sipiConf.getCacheNFiles(), 250);
EXPECT_EQ(sipiConf.getCacheSize(), 20 * 1024 * 1024);
EXPECT_EQ(sipiConf.getCacheNFiles(), 8);
EXPECT_EQ(sipiConf.getCacheHysteresis(), (float) 0.15);
EXPECT_EQ(sipiConf.getScriptDir(), "./scripts");
EXPECT_EQ(sipiConf.getThumbSize(), "!128,128");
EXPECT_EQ(sipiConf.getTmpDir(), "/tmp");
EXPECT_EQ(sipiConf.getLoglevel(), "ERROR");
EXPECT_EQ(sipiConf.getLoglevel(), "DEBUG");
}