allow both dpi and scale to be set for pdfload
pdfload didn't allow both dpi and scale to be set. This patch makes the two settings combine if both are given. thanks le0daniel see https://github.com/libvips/libvips/issues/1824
This commit is contained in:
parent
dc88d6c1e1
commit
0c7b65e156
@ -5,6 +5,7 @@
|
|||||||
- 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]
|
||||||
|
|
||||||
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
|
||||||
|
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user