Home » Javascript » javascript – How to write image url in Spritesmith library?

javascript – How to write image url in Spritesmith library?

Posted by: admin February 26, 2020 Leave a comment

Questions:

It wants a file path from me in the src section of this library, but I want to write the link of the picture, but it doesn’t accept it.

How can I solve this?

Example

// Load in dependencies
var fs = require('fs');
var Spritesmith = require('spritesmith');

// Generate our spritesheet
Spritesmith.run({
  src: [
    __dirname + '/fork.png',
    __dirname + '/github.png',
    __dirname + '/twitter.png'
  ],
  padding: 20 // Exaggerated for visibility, normally 1 or 2
}, function handleResult (err, result) {
  // If there was an error, throw it
  if (err) {
    throw err;
  }

  // Output the image
  fs.writeFileSync(__dirname + '/padding.png', result.image);
  result.coordinates, result.properties; // Coordinates and properties
});

I want to use,

src: [
    'https://example.com/image1.png',
    'https://example.com/image2.png',
    'https://example.com/image3.png'
  ]
How to&Answers: