Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG pipe support #197

Closed
naonak opened this issue Apr 17, 2015 · 5 comments
Closed

SVG pipe support #197

naonak opened this issue Apr 17, 2015 · 5 comments
Labels

Comments

@naonak
Copy link

naonak commented Apr 17, 2015

Hi,

Sharp is just great but I find an issue.

libvips 7.42 and Sharp 0.9.3

Thanks for your help

// Work :
var transformer = sharp('Wikipedia-W-visual-balanced.svg')
  .background('#ffffff')
  .flatten()
  .jpeg()
  .toFile('output.jpg');

// Fail :
var transformer = sharp()
  .background('#ffffff')
  .flatten()
  .jpeg()

http.get('http://upload.wikimedia.org/wikipedia/commons/4/46/Wikipedia-W-visual-balanced.svg', function(response) {

  var writeStream = fs.createWriteStream('output.jpg');
  var stream = response.pipe(transformer).pipe(writeStream);

}).on('error', function (err) {
    console.log('An error occurred!', err);
})

Error: Error: Input buffer contains unsupported image format
    at /mar-sidi/node_modules/sharp/index.js:555:32
@lovell
Copy link
Owner

lovell commented Apr 17, 2015

Hi Fabien, you can see which formats/methods are available in your combination of sharp/libvips versions via the format attribute:

var sharp = require('sharp');
console.dir(sharp.format);

For Stream-based (and Buffer-based) input of SVG and other "magick" formats, you'll need the bleeding edge libvips v8.0.0 (via its master branch on Github), which includes commit jcupitt/libvips@dba1b1d

You'll also need to use the forthcoming v0.10.0 release of sharp, which can be trialled via:

npm install lovell/sharp#judgement

Hope this helps.

@lovell
Copy link
Owner

lovell commented Apr 17, 2015

Watch out for the low-resolution problem of #110 if you're using SVG input.

@naonak
Copy link
Author

naonak commented Apr 20, 2015

Thanks a lot for your answer !

@naonak naonak closed this as completed Apr 20, 2015
@kapouer
Copy link
Contributor

kapouer commented Jan 20, 2016

Using libvips 8.2 from debian/sid and sharp 0.12.2 i get
Error: Input buffer contains unsupported image formatVipsForeignLoad: buffer is not in a known format
using https://github.com/kapouer/url-inspector-daemon/blob/master/lib/sharpie.js

@kapouer
Copy link
Contributor

kapouer commented Jan 20, 2016

Uuuh i see, this is related to #220 and probably the svg i'm testing it with is received gzipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants