mirror of
https://github.com/lovell/sharp.git
synced 2025-07-10 19:10:14 +02:00
Add tilecache before smartcrop to avoid over-computation
This commit is contained in:
parent
ba521fccb4
commit
1fec132dee
@ -22,6 +22,10 @@ Requires libvips v8.6.0.
|
||||
[#977](https://github.com/lovell/sharp/pull/977)
|
||||
[@jardakotesovec](https://github.com/jardakotesovec)
|
||||
|
||||
* Add tilecache before smartcrop to avoid over-computation of previous operations.
|
||||
[#1028](https://github.com/lovell/sharp/issues/1028)
|
||||
[@coffeebite](https://github.com/coffeebite)
|
||||
|
||||
* TIFF output: switch default predictor from 'none' to 'horizontal' to match libvips' behaviour.
|
||||
|
||||
### v0.18 - "*ridge*"
|
||||
|
@ -267,23 +267,6 @@ namespace sharp {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Insert a tile cache to prevent over-computation of any previous operations in the pipeline
|
||||
*/
|
||||
VImage TileCache(VImage image, double const factor) {
|
||||
int tile_width;
|
||||
int tile_height;
|
||||
int scanline_count;
|
||||
vips_get_tile_size(image.get_image(), &tile_width, &tile_height, &scanline_count);
|
||||
double const need_lines = 1.2 * scanline_count / factor;
|
||||
return image.tilecache(VImage::option()
|
||||
->set("tile_width", image.width())
|
||||
->set("tile_height", 10)
|
||||
->set("max_tiles", static_cast<int>(round(1.0 + need_lines / 10.0)))
|
||||
->set("access", VIPS_ACCESS_SEQUENTIAL)
|
||||
->set("threaded", TRUE));
|
||||
}
|
||||
|
||||
VImage Threshold(VImage image, double const threshold, bool const thresholdGrayscale) {
|
||||
if (!thresholdGrayscale) {
|
||||
return image >= threshold;
|
||||
|
@ -72,11 +72,6 @@ namespace sharp {
|
||||
*/
|
||||
VImage Sharpen(VImage image, double const sigma, double const flat, double const jagged);
|
||||
|
||||
/*
|
||||
Insert a tile cache to prevent over-computation of any previous operations in the pipeline
|
||||
*/
|
||||
VImage TileCache(VImage image, double const factor);
|
||||
|
||||
/*
|
||||
Threshold an image
|
||||
*/
|
||||
|
@ -466,6 +466,9 @@ class PipelineWorker : public Nan::AsyncWorker {
|
||||
image = image.extract_area(left, top, width, height);
|
||||
} else {
|
||||
// Attention-based or Entropy-based crop
|
||||
image = image.tilecache(VImage::option()
|
||||
->set("access", baton->accessMethod)
|
||||
->set("threaded", TRUE));
|
||||
image = image.smartcrop(baton->width, baton->height, VImage::option()
|
||||
->set("interesting", baton->crop == 16 ? VIPS_INTERESTING_ENTROPY : VIPS_INTERESTING_ATTENTION));
|
||||
baton->hasCropOffset = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user