How to use datauri - 10 common examples

To help you get started, we’ve selected a few datauri examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ghosh / Crimp / src / main / ipc / FilesHandler.js View on Github external
async optimizeFile(path) {
    try {
      const dataUri = await DataURI(path);

      const originalBuffer = await fs.readFile(path);
      const optimizedBuffer = await imagemin.buffer(originalBuffer, { plugins: imageMinPlugins });
      await fs.writeFile(path, optimizedBuffer);

      return {
        dataUri: dataUri,
        originalSize: originalBuffer.length,
        optimizedSize: optimizedBuffer.length
      }

    } catch (error) {
      return { status: false, originalSize: null, optimizedSize: null }
      console.error('Error: ', error);
    }
  }
github limedocs / limedocs-wiki-converter / src / markdown.js View on Github external
this.mainRenderer.image = function(href, title, text) {
      if (!href.match(/^https?:\/\//)) {
        href = path.resolve(self.wikiPath, href)
        return util.format('<img src="%s">', datauri(href))
      } else {
        return util.format('<img src="%s">', href)
      }
    }
    return this
github limedocs / limedocs-wiki-converter / dist / markdown.js View on Github external
this.mainRenderer.image = function (href, title, text) {
        if (!href.match(/^https?:\/\//)) {
          href = path.resolve(self.wikiPath, href);
          return util.format('<img src="%s">', datauri(href));
        } else {
          return util.format('<img src="%s">', href);
        }
      };
      return this;
github limedocs / limedocs-wiki-converter / src / base-writer.js View on Github external
getLimedocsGeneratedImgData() {
    return datauri(path.resolve(__dirname, '../assets/images/Limedocs-generated.png'))
  }
github fevrcoding / wok / build / gulp-tasks / lib / sass-functions.js View on Github external
'inline-image($path)': function inlineImage(filepath) {
            const imagePath = getFilePath(filepath);
            if (imagePath) {
                return new types.String('url(\'' + datauri(imagePath) + '\')');
            }
            return null;
        }
    };
github limedocs / limedocs-wiki-converter / dist / base-writer.js View on Github external
value: function getLimedocsGeneratedImgData() {
      return datauri(path.resolve(__dirname, '../assets/images/Limedocs-generated.png'));
    }
  }, {
github ezcater / sosia / packages / sosia-puppeteer / PuppeteerBrowserTarget.ts View on Github external
const toDataUri = (page: Page): string =&gt; {
  const html = `
    
    
    
    <style>
      ${page.css}
    </style>
    
    ${page.body}
  `;
  const htmlBuffer = Buffer.from(html, 'utf8');
  const datauri = new Datauri();
  datauri.format('.html', htmlBuffer);
  return datauri.content;
};
github timse / srcset-loader / src / placeholder-loader.js View on Github external
function bufferToDataUri(type, buffer) {
  return new DataUri().format(type, buffer).content;
}
github marmelab / svg_to_png / src / convertHtmlToDataUrl.js View on Github external
export default html => {
    const datauri = new Datauri();
    return datauri.format('.html', html).content;
};
github SAP / yeoman-ui / backend / src / yeomanui.ts View on Github external
private async createGeneratorChoice(genName: string, genPackagePath: string, packageJson: any): Promise {
    let genImageUrl;

    try {
      genImageUrl = await datauri.promise(path.join(genPackagePath, YeomanUI.YEOMAN_PNG));
    } catch (error) {
      genImageUrl = defaultImage.default;
    }

    const genMessage = _.get(packageJson, "description", YeomanUI.defaultMessage);
    const genPrettyName = titleize(humanizeString(genName));
    const genHomepage = _.get(packageJson, "homepage", '');

    return {
      name: genName,
      prettyName: genPrettyName,
      message: genMessage,
      homepage: genHomepage,
      imageUrl: genImageUrl
    };
  }

datauri

Create DataURI scheme easily

MIT
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis

Popular datauri functions