Comments (5)
This tool can create one or more icons all at once (in fact, it can create any arbitrarily large number of icons if you want it to). Providing names for a lot of icons (even just more than one icon) can get confusing and annoying, so I decided not to do that. Instead, you can provide a directory that all icons will be written into.
If you need to create a bunch of icons in a script, you can create each icon and then rename/move it to your preferred name/destination (the Windows command line has ren
or move
to do that), easily achieving the goal.
If you have a good idea how to take in names for all the icons that are created, I would absolutely welcome a PR!
from svg-app-icon.
Right now you just have 'icon,ico' hardcoded. All you have to do is implement a --filename (-f)
option that allows you to specify a custom output filename. And optionally if nothing is supplied than default to the same name as the SVG, just with a .ICO extension. Then I can create a wrapper script to process any number of icons. I'm not very good with JavaScript, otherwise I would implement it myself.
I think one of the major problems in the CLI usage example npx svg-app-icon < input.svg
is the way you're passing in the SVG. In this instance you can't retrieve the original file name from within the script because you're just passing the contents of input.svg
. I would look into refactoring the code to use a different method of passing the svg file into the project.
from svg-app-icon.
Like I said, this module does not produce just one file. It produces 6 by default, but that is customizable and it can produce far more than 6 if you wanted to. There is no option to name any of these files. Please put all of the output files in a named directory using the --destination
flag. If you are unsure what the properties are, please take a look at the CLI section in the readme or run npx svg-app-icon --help
. You can move or rename files as you wish after they are created.
I understand how my library is implemented, and there is very good reason for all of it. If you'd like to discuss my decisions further, feel free to ask about the parts that confuse you. And if you want to contribute, feel free to submit a PR!
from svg-app-icon.
If you'd like to discuss my decisions further, feel free to ask about the parts that confuse you
I've looked through the help for svg-app-icon and I understand all of the options. I guess what I'm confused about is how I would batch process a folder of SVGs to ICO. Here is the relevant portion of Maker.js:
module.exports = async (input, { destination = 'icons', icns = true, ico = true, png = true, svg = true, pngSizes = [32, 256, 512] } = {}) => {
const buffer = Buffer.isBuffer(input) ? input : Buffer.from(input);
if (svg) {
await write(dest(destination, 'icon.svg'), buffer);
}
if (ico) {
await write(dest(destination, 'icon.ico'), await createIco(buffer));
}
if (icns) {
await write(dest(destination, 'icon.icns'), await createIcns(buffer));
}
if (png) {
for (let size of pngSizes) {
await write(dest(destination, `${size}x${size}.png`), await createPng(buffer, size));
}
}
};
As you can see in the following lines:
await write(dest(destination, 'icon.svg'), buffer);
await write(dest(destination, 'icon.ico'), await createIco(buffer));
await write(dest(destination, 'icon.icns'), await createIcns(buffer));
await write(dest(destination,
${size}x${size}.png), await createPng(buffer, size));
The output file names are all hard-coded. How can I batch process a bunch of SVGs to .ICOs without each icon overwriting the last one? Sorry if I'm missing something obvious. If you can point me to the right direction that would be great,
from svg-app-icon.
@visusys A trick given that filename feature is not implemented would be write all files to a temp folder and rename them to the desired filename (and delete the temp folder, if required). I like to do that, for example, with png files.
from svg-app-icon.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svg-app-icon.