question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Electron: SVG from buffer gives error unsupported image object

See original GitHub issue

sharp.format.svg.input[buffer/file/stream] = all true, using sharp 0.18.4 on osx 10.11.6, electron 1.7.5.

Taking the example from the main page:

const roundedCorners = new Buffer(
  '<svg><rect x="0" y="0" width="200" height="200" rx="50" ry="50"/></svg>'
);

const roundedCornerResizer =
  sharp()
    .resize(200, 200)
    .overlayWith(roundedCorners, { cutout: true })
    .png();

This returns error unsupported input object.

I’m trying something similar in my code - take a jpeg and overlay it with an svg from buffer, but I keep running into this error. Any tips to track down what’s going on here?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
vitkrvcommented, Jun 1, 2018

@jpittner, I have had the same problem in Electron. Next solution works for me:

// electron.service.ts
import {Injectable} from '@angular/core';
// ....
import * as buffer from 'buffer';

@Injectable()
export class ElectronService {
   // ....
  buffer: typeof buffer;

  constructor() {
    // Conditional imports
    if (this.isElectron()) {
      // .....
      this.buffer = window.require('buffer');
      // ....
      const roundedCorners = new this.buffer.Buffer(
         '<svg><rect x="0" y="0" width="200" height="200" rx="50" ry="50"/></svg>'
       );
       // ....
    }
  }

  isElectron() {
    return window && window.process && window.process.type;
  }
}

Dependencies:

  • Angular 5.2.9
  • Sharp 0.20.2
  • Electron 1.8.4
0reactions
lovellcommented, Dec 4, 2017

Closing as there has been no update and no further reports. Please re-open with the requested details if this is still occurring.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Unsupported image object", using Tesseract - Stack Overflow
You are passing the string but not the image itself. To fix it just change the line text = pyt.image_to_string(image_file) to text =...
Read more >
Bug listing with status UNCONFIRMED as at 2022/12/28 19 ...
Bug :128538 - "sys-apps/coreutils: /bin/hostname should be installed from coreutils not sys-apps/net-tools" status:UNCONFIRMED resolution: severity:enhancement ...
Read more >
Package List — Spack 0.20.0.dev0 documentation
ANTs is popularly considered a state-of-the-art medical image ... It creates control-flow models of each MPI process and, when a failure occurs, ...
Read more >
An "Unsupported Image Format" exception occurs on loading ...
svg " in a cxImageList the following error message is displayed: "errormessage.png". So how must an SVG icon be made or exported to...
Read more >
System Manual Know-How ecomatmobile CODESYS ... - ifm
CANopen network configuration, status and error handling . ... ifm electronic\CoDeSys V…\Projects\Template_DVD_V… ▻ Open the requested template in CODESYS ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found