Merge branch '8.10'
This commit is contained in:
commit
fa260df262
@ -11,6 +11,8 @@
|
|||||||
- in jpegsave, don't set JFIF resolution if we set EXIF resolution
|
- in jpegsave, don't set JFIF resolution if we set EXIF resolution
|
||||||
- bump minimum libheif version to 1.3 [lovell]
|
- bump minimum libheif version to 1.3 [lovell]
|
||||||
- dzsave in iiif mode could set info.json dimensions off by one [Linden6]
|
- dzsave in iiif mode could set info.json dimensions off by one [Linden6]
|
||||||
|
- pdfload allows dpi and scale to both be set [le0daniel]
|
||||||
|
- allow gaussblur sigma zero, meaning no blur
|
||||||
|
|
||||||
9/8/20 started 8.10.1
|
9/8/20 started 8.10.1
|
||||||
- fix markdown -> xml conversion in doc generation
|
- fix markdown -> xml conversion in doc generation
|
||||||
|
@ -4,6 +4,9 @@
|
|||||||
* - from vips_sharpen()
|
* - from vips_sharpen()
|
||||||
* 19/11/14
|
* 19/11/14
|
||||||
* - change parameters to be more imagemagick-like
|
* - change parameters to be more imagemagick-like
|
||||||
|
* 21/9/20
|
||||||
|
* - allow sigma zero, meaning no blur
|
||||||
|
* - sigma < 0.2 is just copy
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -73,23 +76,33 @@ vips_gaussblur_build( VipsObject *object )
|
|||||||
if( VIPS_OBJECT_CLASS( vips_gaussblur_parent_class )->build( object ) )
|
if( VIPS_OBJECT_CLASS( vips_gaussblur_parent_class )->build( object ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
|
||||||
if( vips_gaussmat( &t[0], gaussblur->sigma, gaussblur->min_ampl,
|
/* vips_gaussmat() will make a 1x1 pixel mask for anything smaller than
|
||||||
"separable", TRUE,
|
* this.
|
||||||
"precision", gaussblur->precision,
|
*/
|
||||||
NULL ) )
|
if( sigma < 0.2 ) {
|
||||||
return( -1 );
|
if( vips_copy( gaussblur->in, &t[1], NULL ) )
|
||||||
|
return( -1 );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if( vips_gaussmat( &t[0],
|
||||||
|
gaussblur->sigma, gaussblur->min_ampl,
|
||||||
|
"separable", TRUE,
|
||||||
|
"precision", gaussblur->precision,
|
||||||
|
NULL ) )
|
||||||
|
return( -1 );
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf( "gaussblur: blurring with:\n" );
|
printf( "gaussblur: blurring with:\n" );
|
||||||
vips_matrixprint( t[0], NULL );
|
vips_matrixprint( t[0], NULL );
|
||||||
#endif /*DEBUG*/
|
#endif /*DEBUG*/
|
||||||
|
|
||||||
g_info( "gaussblur mask width %d", t[0]->Xsize );
|
g_info( "gaussblur mask width %d", t[0]->Xsize );
|
||||||
|
|
||||||
if( vips_convsep( gaussblur->in, &t[1], t[0],
|
if( vips_convsep( gaussblur->in, &t[1], t[0],
|
||||||
"precision", gaussblur->precision,
|
"precision", gaussblur->precision,
|
||||||
NULL ) )
|
NULL ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
g_object_set( object, "out", vips_image_new(), NULL );
|
g_object_set( object, "out", vips_image_new(), NULL );
|
||||||
|
|
||||||
@ -132,7 +145,7 @@ vips_gaussblur_class_init( VipsGaussblurClass *class )
|
|||||||
_( "Sigma of Gaussian" ),
|
_( "Sigma of Gaussian" ),
|
||||||
VIPS_ARGUMENT_REQUIRED_INPUT,
|
VIPS_ARGUMENT_REQUIRED_INPUT,
|
||||||
G_STRUCT_OFFSET( VipsGaussblur, sigma ),
|
G_STRUCT_OFFSET( VipsGaussblur, sigma ),
|
||||||
0.01, 1000, 1.5 );
|
0.0, 1000, 1.5 );
|
||||||
|
|
||||||
VIPS_ARG_DOUBLE( class, "min_ampl", 3,
|
VIPS_ARG_DOUBLE( class, "min_ampl", 3,
|
||||||
_( "Minimum amplitude" ),
|
_( "Minimum amplitude" ),
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
* - reopen the input if we minimised too early
|
* - reopen the input if we minimised too early
|
||||||
* 11/3/20
|
* 11/3/20
|
||||||
* - move on top of VipsSource
|
* - move on top of VipsSource
|
||||||
|
* 21/9/20
|
||||||
|
* - allow dpi and scale to both be set [le0daniel]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -109,10 +111,14 @@ typedef struct _VipsForeignLoadPdf {
|
|||||||
*/
|
*/
|
||||||
double dpi;
|
double dpi;
|
||||||
|
|
||||||
/* Calculate this from DPI. At 72 DPI, we render 1:1 with cairo.
|
/* Scale by this factor.
|
||||||
*/
|
*/
|
||||||
double scale;
|
double scale;
|
||||||
|
|
||||||
|
/* The total scale factor we render with.
|
||||||
|
*/
|
||||||
|
double total_scale;
|
||||||
|
|
||||||
/* Background colour.
|
/* Background colour.
|
||||||
*/
|
*/
|
||||||
VipsArrayDouble *background;
|
VipsArrayDouble *background;
|
||||||
@ -170,8 +176,7 @@ vips_foreign_load_pdf_build( VipsObject *object )
|
|||||||
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if( !vips_object_argument_isset( object, "scale" ) )
|
pdf->total_scale = pdf->scale * pdf->dpi / 72.0;
|
||||||
pdf->scale = pdf->dpi / 72.0;
|
|
||||||
|
|
||||||
pdf->stream = vips_g_input_stream_new_from_source( pdf->source );
|
pdf->stream = vips_g_input_stream_new_from_source( pdf->source );
|
||||||
if( !(pdf->doc = poppler_document_new_from_stream( pdf->stream,
|
if( !(pdf->doc = poppler_document_new_from_stream( pdf->stream,
|
||||||
@ -338,8 +343,8 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load )
|
|||||||
* does round to nearest. Without this, things like
|
* does round to nearest. Without this, things like
|
||||||
* shrink-on-load will break.
|
* shrink-on-load will break.
|
||||||
*/
|
*/
|
||||||
pdf->pages[i].width = VIPS_RINT( width * pdf->scale );
|
pdf->pages[i].width = VIPS_RINT( width * pdf->total_scale );
|
||||||
pdf->pages[i].height = VIPS_RINT( height * pdf->scale );
|
pdf->pages[i].height = VIPS_RINT( height * pdf->total_scale );
|
||||||
|
|
||||||
if( pdf->pages[i].width > pdf->image.width )
|
if( pdf->pages[i].width > pdf->image.width )
|
||||||
pdf->image.width = pdf->pages[i].width;
|
pdf->image.width = pdf->pages[i].width;
|
||||||
@ -421,10 +426,10 @@ vips_foreign_load_pdf_generate( VipsRegion *or,
|
|||||||
cr = cairo_create( surface );
|
cr = cairo_create( surface );
|
||||||
cairo_surface_destroy( surface );
|
cairo_surface_destroy( surface );
|
||||||
|
|
||||||
cairo_scale( cr, pdf->scale, pdf->scale );
|
cairo_scale( cr, pdf->total_scale, pdf->total_scale );
|
||||||
cairo_translate( cr,
|
cairo_translate( cr,
|
||||||
(pdf->pages[i].left - rect.left) / pdf->scale,
|
(pdf->pages[i].left - rect.left) / pdf->total_scale,
|
||||||
(pdf->pages[i].top - rect.top) / pdf->scale );
|
(pdf->pages[i].top - rect.top) / pdf->total_scale );
|
||||||
|
|
||||||
/* poppler is single-threaded, but we don't need to lock since
|
/* poppler is single-threaded, but we don't need to lock since
|
||||||
* we're running inside a non-threaded tilecache.
|
* we're running inside a non-threaded tilecache.
|
||||||
@ -862,9 +867,8 @@ vips_foreign_load_pdf_is_a( const char *filename )
|
|||||||
* left. Set to -1 to mean "until the end of the document". Use vips_grid()
|
* left. Set to -1 to mean "until the end of the document". Use vips_grid()
|
||||||
* to change page layout.
|
* to change page layout.
|
||||||
*
|
*
|
||||||
* Use @dpi to set the rendering resolution. The default is 72. Alternatively,
|
* Use @dpi to set the rendering resolution. The default is 72. Additionally,
|
||||||
* you can scale the rendering from the default 1 point == 1 pixel by
|
* you can scale by setting @scale. If you set both, they combine.
|
||||||
* setting @scale.
|
|
||||||
*
|
*
|
||||||
* Use @background to set the background RGBA colour. The default is 255
|
* Use @background to set the background RGBA colour. The default is 255
|
||||||
* (solid white), use eg. 0 for a transparent background.
|
* (solid white), use eg. 0 for a transparent background.
|
||||||
|
@ -736,24 +736,6 @@ vips_thumbnail_build( VipsObject *object )
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
in = t[2];
|
in = t[2];
|
||||||
|
|
||||||
/* If there's an alpha, we have to premultiply before shrinking. See
|
|
||||||
* https://github.com/libvips/libvips/issues/291
|
|
||||||
*/
|
|
||||||
have_premultiplied = FALSE;
|
|
||||||
if( vips_image_hasalpha( in ) ) {
|
|
||||||
g_info( "premultiplying alpha" );
|
|
||||||
if( vips_premultiply( in, &t[3], NULL ) )
|
|
||||||
return( -1 );
|
|
||||||
have_premultiplied = TRUE;
|
|
||||||
|
|
||||||
/* vips_premultiply() makes a float image. When we
|
|
||||||
* vips_unpremultiply() below, we need to cast back to the
|
|
||||||
* pre-premultiply format.
|
|
||||||
*/
|
|
||||||
unpremultiplied_format = in->BandFmt;
|
|
||||||
in = t[3];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Shrink to preshrunk_page_height, so we work for multi-page images.
|
/* Shrink to preshrunk_page_height, so we work for multi-page images.
|
||||||
*/
|
*/
|
||||||
vips_thumbnail_calculate_shrink( thumbnail,
|
vips_thumbnail_calculate_shrink( thumbnail,
|
||||||
@ -771,6 +753,26 @@ vips_thumbnail_build( VipsObject *object )
|
|||||||
vshrink = (double) in->Ysize / target_image_height;
|
vshrink = (double) in->Ysize / target_image_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If there's an alpha, we have to premultiply before shrinking. See
|
||||||
|
* https://github.com/libvips/libvips/issues/291
|
||||||
|
*/
|
||||||
|
have_premultiplied = FALSE;
|
||||||
|
if( vips_image_hasalpha( in ) &&
|
||||||
|
hshrink != 1.0 &&
|
||||||
|
vshrink != 1.0 ) {
|
||||||
|
g_info( "premultiplying alpha" );
|
||||||
|
if( vips_premultiply( in, &t[3], NULL ) )
|
||||||
|
return( -1 );
|
||||||
|
have_premultiplied = TRUE;
|
||||||
|
|
||||||
|
/* vips_premultiply() makes a float image. When we
|
||||||
|
* vips_unpremultiply() below, we need to cast back to the
|
||||||
|
* pre-premultiply format.
|
||||||
|
*/
|
||||||
|
unpremultiplied_format = in->BandFmt;
|
||||||
|
in = t[3];
|
||||||
|
}
|
||||||
|
|
||||||
if( vips_resize( in, &t[4], 1.0 / hshrink,
|
if( vips_resize( in, &t[4], 1.0 / hshrink,
|
||||||
"vscale", 1.0 / vshrink,
|
"vscale", 1.0 / vshrink,
|
||||||
NULL ) )
|
NULL ) )
|
||||||
|
Loading…
Reference in New Issue
Block a user