better pdfload page size rounding
We were doing simple round down for page size with @scale param. But this makes it very sensitive to rounding errors, so do rint() instead. vips-resize() does rint() on the output size as well for the same reason. See https://github.com/libvips/libvips/issues/1297#issuecomment-487682785
This commit is contained in:
parent
7326a409c6
commit
29d29533d4
|
@ -297,8 +297,12 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load )
|
||||||
poppler_page_get_size( pdf->page, &width, &height );
|
poppler_page_get_size( pdf->page, &width, &height );
|
||||||
pdf->pages[i].left = 0;
|
pdf->pages[i].left = 0;
|
||||||
pdf->pages[i].top = top;
|
pdf->pages[i].top = top;
|
||||||
pdf->pages[i].width = width * pdf->scale;
|
/* We do round to nearest, in the same way that vips_resize()
|
||||||
pdf->pages[i].height = height * pdf->scale;
|
* does round to nearest. Without this, things like
|
||||||
|
* shrink-on-load will break.
|
||||||
|
*/
|
||||||
|
pdf->pages[i].width = VIPS_RINT( width * pdf->scale );
|
||||||
|
pdf->pages[i].height = VIPS_RINT( height * pdf->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;
|
||||||
|
|
|
@ -341,10 +341,14 @@ vips_foreign_load_pdf_header( VipsForeignLoad *load )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
pdf->pages[i].left = 0;
|
pdf->pages[i].left = 0;
|
||||||
pdf->pages[i].top = top;
|
pdf->pages[i].top = top;
|
||||||
pdf->pages[i].width =
|
/* We do round to nearest, in the same way that vips_resize()
|
||||||
FPDF_GetPageWidth( pdf->page ) * pdf->scale;
|
* does round to nearest. Without this, things like
|
||||||
pdf->pages[i].height =
|
* shrink-on-load will break.
|
||||||
FPDF_GetPageHeight( pdf->page ) * pdf->scale;
|
*/
|
||||||
|
pdf->pages[i].width = VIPS_RINT(
|
||||||
|
FPDF_GetPageWidth( pdf->page ) * pdf->scale );
|
||||||
|
pdf->pages[i].height = VIPS_RINT(
|
||||||
|
FPDF_GetPageHeight( pdf->page ) * pdf->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;
|
||||||
|
|
Loading…
Reference in New Issue