From 91457e455a10518fe413cae43ee7483a03071975 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Mon, 19 Jun 2017 09:31:49 +0100 Subject: [PATCH] add "page-height" save property --- ChangeLog | 1 + libvips/foreign/foreign.c | 13 +++++++++++++ libvips/foreign/tiffsave.c | 2 ++ libvips/include/vips/foreign.h | 4 ++++ 4 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 32a76e18..f24b86c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,7 @@ - add FORCE resize mode to break aspect ratio - add vips_thumbnail_image() - better prefix guessing on Windows, thanks tumagonx +- savers support a "page_height" option for multipage save 12/6/17 started 8.5.7 - transform cmyk->rgb automatically on write if there's an embedded profile diff --git a/libvips/foreign/foreign.c b/libvips/foreign/foreign.c index 9452401b..a8025a37 100644 --- a/libvips/foreign/foreign.c +++ b/libvips/foreign/foreign.c @@ -16,6 +16,8 @@ * - remove max-alpha stuff, this is now automatic * 12/6/17 * - transform cmyk->rgb if there's an embedded profile + * 16/6/17 + * - add page_height */ /* @@ -1485,6 +1487,10 @@ vips_foreign_save_build( VipsObject *object ) save->background ) ) return( -1 ); + if( save->page_height ) + vips_image_set_int( ready, + VIPS_META_PAGE_HEIGHT, save->page_height ); + VIPS_UNREF( save->ready ); save->ready = ready; } @@ -1570,6 +1576,13 @@ vips_foreign_save_class_init( VipsForeignSaveClass *class ) VIPS_ARGUMENT_OPTIONAL_INPUT, G_STRUCT_OFFSET( VipsForeignSave, background ), VIPS_TYPE_ARRAY_DOUBLE ); + + VIPS_ARG_INT( class, "page_height", 8, + _( "Page height" ), + _( "Set page height for multipage save" ), + VIPS_ARGUMENT_OPTIONAL_INPUT, + G_STRUCT_OFFSET( VipsForeignSave, page_height ), + 0, VIPS_MAX_COORD, 0 ); } static void diff --git a/libvips/foreign/tiffsave.c b/libvips/foreign/tiffsave.c index 806d0540..c5b92074 100644 --- a/libvips/foreign/tiffsave.c +++ b/libvips/foreign/tiffsave.c @@ -472,6 +472,7 @@ vips_foreign_save_tiff_buffer_init( VipsForeignSaveTiffBuffer *buffer ) * * @bigtiff: set %TRUE to write a BigTiff file * * @properties: set %TRUE to write an IMAGEDESCRIPTION tag * * @strip: set %TRUE to block metadata save + * * @page_height: %gint for page height for multi-page save * * Write a VIPS image to a file as TIFF. * @@ -587,6 +588,7 @@ vips_tiffsave( VipsImage *in, const char *filename, ... ) * * @bigtiff: set %TRUE to write a BigTiff file * * @properties: set %TRUE to write an IMAGEDESCRIPTION tag * * @strip: set %TRUE to block metadata save + * * @page_height: %gint for page height for multi-page save * * As vips_tiffsave(), but save to a memory buffer. * diff --git a/libvips/include/vips/foreign.h b/libvips/include/vips/foreign.h index c77a7f37..d551dddd 100644 --- a/libvips/include/vips/foreign.h +++ b/libvips/include/vips/foreign.h @@ -279,6 +279,10 @@ typedef struct _VipsForeignSave { */ VipsArrayDouble *background; + /* Set to non-zero to set the page size for multi-page save. + */ + int page_height; + /*< public >*/ /* The image we are to save, as supplied by our caller.