mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 10:30:15 +02:00
Add SVG and PSD fixtures and tests
This commit is contained in:
parent
a56102a209
commit
247b607afd
17
test/fixtures/Wikimedia-logo.svg
vendored
Normal file
17
test/fixtures/Wikimedia-logo.svg
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" standalone="yes"?>
|
||||||
|
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"
|
||||||
|
id="Wikimedia logo"
|
||||||
|
viewBox="-599 -599 1198 1198" width="1024" height="1024">
|
||||||
|
<defs>
|
||||||
|
<clipPath id="mask">
|
||||||
|
<path d="M 47.5,-87.5 v 425 h -95 v -425 l -552,-552 v 1250 h 1199 v -1250 z" />
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
<g clip-path="url(#mask)">
|
||||||
|
<circle id="green parts" fill="#396" r="336.5"/>
|
||||||
|
<circle id="blue arc" fill="none" stroke="#069" r="480.25" stroke-width="135.5" />
|
||||||
|
</g>
|
||||||
|
<circle fill="#900" cy="-379.5" r="184.5" id="red circle"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 692 B |
BIN
test/fixtures/free-gearhead-pack.psd
vendored
Normal file
BIN
test/fixtures/free-gearhead-pack.psd
vendored
Normal file
Binary file not shown.
2
test/fixtures/index.js
vendored
2
test/fixtures/index.js
vendored
@ -21,6 +21,8 @@ module.exports = {
|
|||||||
inputWebP: getPath('4.webp'), // http://www.gstatic.com/webp/gallery/4.webp
|
inputWebP: getPath('4.webp'), // http://www.gstatic.com/webp/gallery/4.webp
|
||||||
inputTiff: getPath('G31D.TIF'), // http://www.fileformat.info/format/tiff/sample/e6c9a6e5253348f4aef6d17b534360ab/index.htm
|
inputTiff: getPath('G31D.TIF'), // http://www.fileformat.info/format/tiff/sample/e6c9a6e5253348f4aef6d17b534360ab/index.htm
|
||||||
inputGif: getPath('Crash_test.gif'), // http://upload.wikimedia.org/wikipedia/commons/e/e3/Crash_test.gif
|
inputGif: getPath('Crash_test.gif'), // http://upload.wikimedia.org/wikipedia/commons/e/e3/Crash_test.gif
|
||||||
|
inputSvg: getPath('Wikimedia-logo.svg'), // http://commons.wikimedia.org/wiki/File:Wikimedia-logo.svg
|
||||||
|
inputPsd: getPath('free-gearhead-pack.psd'), // https://dribbble.com/shots/1624241-Free-Gearhead-Vector-Pack
|
||||||
|
|
||||||
outputJpg: getPath('output.jpg'),
|
outputJpg: getPath('output.jpg'),
|
||||||
outputPng: getPath('output.png'),
|
outputPng: getPath('output.png'),
|
||||||
|
@ -400,6 +400,32 @@ describe('Input/output', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Convert SVG to PNG', function(done) {
|
||||||
|
sharp(fixtures.inputSvg)
|
||||||
|
.resize(100, 100)
|
||||||
|
.png()
|
||||||
|
.toFile(fixtures.path('output.svg.png'), function(err, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual('png', info.format);
|
||||||
|
assert.strictEqual(100, info.width);
|
||||||
|
assert.strictEqual(100, info.height);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Convert PSD to PNG', function(done) {
|
||||||
|
sharp(fixtures.inputPsd)
|
||||||
|
.resize(320, 240)
|
||||||
|
.png()
|
||||||
|
.toFile(fixtures.path('output.psd.png'), function(err, info) {
|
||||||
|
if (err) throw err;
|
||||||
|
assert.strictEqual('png', info.format);
|
||||||
|
assert.strictEqual(320, info.width);
|
||||||
|
assert.strictEqual(240, info.height);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if (semver.gte(sharp.libvipsVersion(), '7.40.0')) {
|
if (semver.gte(sharp.libvipsVersion(), '7.40.0')) {
|
||||||
it('Load TIFF from Buffer [libvips ' + sharp.libvipsVersion() + '>=7.40.0]', function(done) {
|
it('Load TIFF from Buffer [libvips ' + sharp.libvipsVersion() + '>=7.40.0]', function(done) {
|
||||||
var inputTiffBuffer = fs.readFileSync(fixtures.inputTiff);
|
var inputTiffBuffer = fs.readFileSync(fixtures.inputTiff);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user