Convert some SVG files into PNG using ImageMagick's convert command. Run the conversions in parallel to save time. This is safer than robinro's forkbomb approach :-) xargs runs four processes at a time -P4
Convert some SVG files into PNG using ImageMagick's convert command.
Use GNU Parallel: short, easy to read, and will run one job per core.
Convert an SVG to PNG and then crush the filesize brutally with pngcrush. Good for icons and website junk that you want to keep small, expecially before base64 encoding.
Uses inkscape, not imagemagick, as IM doesn't always handle gradients well. This way also seems to sometime save some file size (eg. 619 with Inkscape compared to 695 with IM).
IM can do general images:
img2png(){ png="${1%.*}.png"; convert -background none "$1" "$png" && pngcrush -brute -rem alla -rem text "$png" "$png.new" && mv "$png.new" "$png"; }
convert all *.svg to png _in parallel_ this speeds up the conversion for many files, but might also not be feasible for a large number of files
Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?
You must be signed in to comment.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for:
echo "${i%.png}.svg"
Remove ".png" from the end of the variable i (and tack .svg on).echo "${i/.svg/.png}"
will also work but it would get confused on file.svg.txt So, a tidier version of your command would look like:for i in *; do inkscape "$i" --export-png="${i%.svg}.png}"; done
for i in *; do inkscape "$i" --export-png="${i%.svg}.png"; done