node svg转png

    技术2022-07-11  115

    node svg转png

    Automating and manipulating media is a fascination of mine, partly because I don't understand the magic behind it and partly because the idea of turning one thing into another is fun and useful.  That latest media tool that has piqued my interest is a JavaScript tool called psd.js.

    自动化和操纵媒体是我的一种着迷,部分是因为我不了解其背后的魔力,部分是因为将一件事变成另一件事的想法很有趣且有用。 引起我兴趣的最新媒体工具是一个名为psd.jsJavaScript工具。

    psd.js is a project that allows you to read PSD files, including:

    psd.js是一个项目,可让您读取PSD文件,包括:

    Document structure and size

    文件结构和尺寸 Layer/folder size + positioning, names, visibility, and opacity

    图层/文件夹大小+位置,名称,可见性和不透明度

    Font data (via psd-enginedata)

    字体数据(通过psd-enginedata )

    Text area contents

    文字区域内容 Font names, sizes, and colors

    字体名称,大小和颜色 Color mode and bit-depth

    色彩模式和位深度 Vector mask data

    矢量蒙版数据 Flattened image data

    展平的图像数据 Layer comps

    图层组合

    What the media converter and JavaScript lover in me found most awesome was one basic feature: converting a PSD to PNG with JavaScript!

    我心中的媒体转换器和JavaScript爱好者发现的最棒的功能是一个基本功能:使用JavaScript将PSD转换为PNG!

    var PSD = require('psd'); PSD.open('homepage.psd').then(function (psd) { return psd.image.saveAsPng('homepage.png'); }).then(function () { console.log('Finished!'); });

    That's a nice, tidy API there and I love that it doesn't require anything other than JavaScript (many other Node.js image libraries require ImageMagick on the machine).  Of course converting PSD to PNG is easy with ImageMagick too, but being able to use Node.js instead opens a whole host of opportunity!

    那是一个很好的,整洁的API,我喜欢它除了JavaScript不需要任何东西(许多其他Node.js图像库在机器上都需要ImageMagick)。 当然, 使用ImageMagick也很容易将PSD转换为PNG ,但是能够使用Node.js却带来了很多机会!

    翻译自: https://davidwalsh.name/convert-psd-png

    node svg转png

    相关资源:NodeJS之SVG转图片下载方案
    Processed: 0.010, SQL: 9