add note on svgload improvement

This commit is contained in:
John Cupitt 2017-09-17 05:20:48 +01:00
parent 99053d41cb
commit b2f66a3968
2 changed files with 9 additions and 6 deletions

View File

@ -20,6 +20,7 @@
- remove python tests ... moved to pyvips test suite - remove python tests ... moved to pyvips test suite
- vips7 and vips8 python bindings default to off ... use the new pyvips - vips7 and vips8 python bindings default to off ... use the new pyvips
binding instead binding instead
- better svgload: larger output, handle missing width/height, thanks lovell
29/8/17 started 8.5.9 29/8/17 started 8.5.9
- make --fail stop jpeg read on any libjpeg warning, thanks @mceachen - make --fail stop jpeg read on any libjpeg warning, thanks @mceachen

View File

@ -10,6 +10,8 @@
* - fix DPI mixup, thanks Fosk * - fix DPI mixup, thanks Fosk
* 9/9/17 * 9/9/17
* - limit max tile width to 30k pixels to prevent overflow in render * - limit max tile width to 30k pixels to prevent overflow in render
* 17/9/17 lovell
* - handle scaling of svg files missing width and height attributes
*/ */
/* /*
@ -130,8 +132,7 @@ vips_foreign_load_svg_get_flags( VipsForeignLoad *load )
} }
static void static void
vips_foreign_load_svg_parse( VipsForeignLoadSvg *svg, vips_foreign_load_svg_parse( VipsForeignLoadSvg *svg, VipsImage *out )
VipsImage *out )
{ {
RsvgDimensionData dimensions; RsvgDimensionData dimensions;
int width; int width;
@ -154,14 +155,16 @@ vips_foreign_load_svg_parse( VipsForeignLoadSvg *svg,
rsvg_handle_get_dimensions( svg->page, &dimensions ); rsvg_handle_get_dimensions( svg->page, &dimensions );
if( width == dimensions.width && height == dimensions.height ) { if( width == dimensions.width && height == dimensions.height ) {
/* SVG without width and height always reports same dimensions /* SVG without width and height always reports the same
* regardless of dpi. Apply dpi/scale using cairo instead. * dimensions regardless of dpi. Apply dpi/scale using
* cairo instead.
*/ */
svg->cairo_scale = scale; svg->cairo_scale = scale;
width = width * scale; width = width * scale;
height = height * scale; height = height * scale;
} else { } else {
/* SVG with width and height reports correctly scaled dimensions. /* SVG with width and height reports correctly scaled
* dimensions.
*/ */
width = dimensions.width; width = dimensions.width;
height = dimensions.height; height = dimensions.height;
@ -516,7 +519,6 @@ vips_foreign_load_svg_is_a_buffer( const void *buf, size_t len )
for( i = 0; i < 24; i++ ) for( i = 0; i < 24; i++ )
if( !isascii( str[i] ) ) if( !isascii( str[i] ) )
return( FALSE ); return( FALSE );
for( i = 0; i < 300 && i < len - 5; i++ ) for( i = 0; i < 300 && i < len - 5; i++ )
if( g_ascii_strncasecmp( str + i, "<svg", 4 ) == 0 ) if( g_ascii_strncasecmp( str + i, "<svg", 4 ) == 0 )
return( TRUE ); return( TRUE );