File tree 2 files changed +16
-1
lines changed
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 80
80
"install" : " (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)" ,
81
81
"clean" : " rm -rf node_modules/ build/ vendor/ .nyc_output/ coverage/ test/fixtures/output.*" ,
82
82
"test" : " semistandard && cpplint && npm run test-unit && npm run test-licensing" ,
83
- "test-unit" : " nyc --reporter=lcov --branches=99 mocha --parallel -- slow=1000 --timeout=60000 ./test/unit/*.js" ,
83
+ "test-unit" : " nyc --reporter=lcov --branches=99 mocha --slow=1000 --timeout=60000 ./test/unit/*.js" ,
84
84
"test-licensing" : " license-checker --production --summary --onlyAllow=\" Apache-2.0;BSD;ISC;MIT\" " ,
85
85
"test-coverage" : " ./test/coverage/report.sh" ,
86
86
"test-leak" : " ./test/leak/leak.sh" ,
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
+ const fs = require ( 'fs' ) ;
3
4
const assert = require ( 'assert' ) ;
4
5
5
6
const sharp = require ( '../../' ) ;
@@ -99,4 +100,18 @@ describe('SVG input', function () {
99
100
fixtures . assertSimilar ( fixtures . expected ( 'svg-embedded.png' ) , data , done ) ;
100
101
} ) ;
101
102
} ) ;
103
+
104
+ it ( 'Converts SVG with truncated embedded PNG' , async ( ) => {
105
+ const truncatedPng = fs . readFileSync ( fixtures . inputPngTruncated ) . toString ( 'base64' ) ;
106
+ const svg = `<?xml version="1.0" encoding="UTF-8"?>
107
+ <svg width="294" height="240" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
108
+ <image width="294" height="240" xlink:href="data:image/png;base64,${ truncatedPng } "/>
109
+ </svg>` ;
110
+
111
+ const { info } = await sharp ( Buffer . from ( svg ) ) . toBuffer ( { resolveWithObject : true } ) ;
112
+ assert . strictEqual ( info . format , 'png' ) ;
113
+ assert . strictEqual ( info . width , 294 ) ;
114
+ assert . strictEqual ( info . height , 240 ) ;
115
+ assert . strictEqual ( info . channels , 4 ) ;
116
+ } ) ;
102
117
} ) ;
You can’t perform that action at this time.
0 commit comments