Skip to content

Commit 4811f1e

Browse files
kleisaukejcupitt
andauthored
tiffsave: honor disc threshold during pyramid save (#4349)
See: kleisauke/net-vips#245. Co-authored-by: John Cupitt <jcupitt@gmail.com>
1 parent f24c62e commit 4811f1e

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

ChangeLog

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- fix MSVC compile error [na-trium-144]
1616
- exif: ensure enumerated entries can to converted to string values [lovell]
1717
- gifsave: add support for eval callback, ensure correct return code [lovell]
18+
- tiffsave: honor disc threshold during pyramid save [kleisauke]
1819
- fill_nearest: fix a leak
1920

2021
10/10/24 8.16.0

libvips/foreign/vips2tiff.c

+10-3
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,16 @@ wtiff_layer_init(Wtiff *wtiff, Layer **layer, Layer *above,
475475
(*layer)->target = wtiff->target;
476476
g_object_ref((*layer)->target);
477477
}
478-
else
479-
(*layer)->target =
480-
vips_target_new_temp(wtiff->target);
478+
else {
479+
const guint64 disc_threshold = vips_get_disc_threshold();
480+
const guint64 layer_size =
481+
VIPS_IMAGE_SIZEOF_PEL(wtiff->ready) * width * height;
482+
483+
if (layer_size > disc_threshold)
484+
(*layer)->target = vips_target_new_temp(wtiff->target);
485+
else
486+
(*layer)->target = vips_target_new_to_memory();
487+
}
481488

482489
/*
483490
printf("wtiff_layer_init: sub = %d, width = %d, height = %d\n",

libvips/iofuncs/target.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ vips_target_new_to_file(const char *filename)
382382
*
383383
* See also: vips_target_new_to_file().
384384
*
385-
* Returns: a new #VipsConnection
385+
* Returns: a new target.
386386
*/
387387
VipsTarget *
388388
vips_target_new_to_memory(void)

0 commit comments

Comments
 (0)