Skip to content

Commit

Permalink
WIP: add shrink-on-load support to openslide
Browse files Browse the repository at this point in the history
  • Loading branch information
lovell committed May 28, 2020
1 parent 25b964e commit f5f1654
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/pipeline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,10 @@ class PipelineWorker : public Napi::AsyncWorker {
}
if (
xshrink == yshrink && xshrink >= 2 * shrink_on_load_factor &&
(inputImageType == sharp::ImageType::JPEG || inputImageType == sharp::ImageType::WEBP) &&
baton->gamma == 0 && baton->topOffsetPre == -1 && baton->trimThreshold == 0.0
baton->gamma == 0 && baton->topOffsetPre == -1 && baton->trimThreshold == 0.0 && (
inputImageType == sharp::ImageType::JPEG ||
inputImageType == sharp::ImageType::WEBP ||
inputImageType == sharp::ImageType::OPENSLIDE)
) {
if (xshrink >= 8 * shrink_on_load_factor) {
xfactor = xfactor / 8;
Expand All @@ -252,8 +254,12 @@ class PipelineWorker : public Napi::AsyncWorker {
// Reload input using shrink-on-load
vips::VOption *option = VImage::option()
->set("access", baton->input->access)
->set("shrink", shrink_on_load)
->set("fail", baton->input->failOnError);
if (inputImageType == sharp::ImageType::JPEG) {
option->set("shrink", shrink_on_load);
} else {
option->set("level", 1.0 / static_cast<double>(shrink_on_load));
}
if (baton->input->buffer != nullptr) {
VipsBlob *blob = vips_blob_new(nullptr, baton->input->buffer, baton->input->bufferLength);
if (inputImageType == sharp::ImageType::JPEG) {
Expand Down

0 comments on commit f5f1654

Please sign in to comment.