You are not logged in.
Hi
So I'm trying to convert all these SVG's to PNG's via ImageMagick. If I'm not wrong, the command is 'convert -define /path/to/icon.svg /path/to/icon.png'. Well that takes a long time with all those icons in yasis, so I thought that a script would help, but I don't know how it should look?
But at least something like this:
#!/bin/sh
for i in *;
do
convert -define ./scalable/apps/$i ./48x48/apps/$i;
done
That's just bring us the problem that the SVG's aren't converted to PNG's, so how do I do it?
Arch - It's something refreshing
Offline
I'd try:
list=`find * -type f -name "*.svg"`
for i in $list ; do
convert -define ./scalable/apps/$i ./48x48/apps/$i
done
Not convinced ./48x48/apps/$i will give you what you want though, surely the output file will be called *.svg anyway? Even if it is a .png file...
Offline
I'd try:
list=`find * -type f -name "*.svg"` for i in $list ; do convert -define ./scalable/apps/$i ./48x48/apps/$i done
Not convinced ./48x48/apps/$i will give you what you want though, surely the output file will be called *.svg anyway? Even if it is a .png file...
I thought something like to cut of ".svg" extension and replace it with ".png". But I'll try it to se if it works.
Arch - It's something refreshing
Offline
No it doesn't work. I got this output:
convert: missing an image filename `./48x48/apps/22x22/filesystems/gnome-fs-network.svg'.
convert: missing an image filename `./48x48/apps/24x24/apps/gnome-window-manager.svg'.
convert: missing an image filename `./48x48/apps/24x24/devices/SVGs/gnome-dev-floppy.svg'.
convert: missing an image filename `./48x48/apps/24x24/devices/SVGs/gnome-dev-cdrw.svg'.
convert: missing an image filename `./48x48/apps/24x24/devices/SVGs/gnome-dev-disc-dvdr.svg'.
...
And it continues.
Arch - It's something refreshing
Offline
If all of your svg images are in one directory, you can run this script. The only drawback is that your files will go from "image.svg" to "image.svg.png". It works though. If you feel like the naming is no good, you could do a batch renaming with 'rename'.
for img in `ls *.svg`
do
convert $img $img.png
done
Offline
Renaming *.svg.png to *.png:
1. execute the code of the above post inside ./scalable/apps/, then do:
cd ../..
mv ./scalable/apps/*.svg.png ./48x48/apps/
cd ./48x48/apps
ls *.svg.png > chgname.sh
sed -i "s|^.*$|& &|" chgname.sh
sed -i "s|^|mv |" chgname.sh
sed -i "s|svg.png$|png|" chgname.sh
sh chgname.sh
rm chgname.sh
"...archoholism is a hard disease to cure..."
Archlinux Brasil
Offline
The following will rename the files and give them the correct extensions. I've also removed the -define option. It doesn't seem to be necessary and was incomplete.
#!/bin/bash
list=`find * -type f -name "*.svg"`
for i in $list ; do
convert ./scalable/apps/$i ./48x48/apps/$(basename $i .svg).png
done
Offline
I'm going for the pretty code award:
for img in `ls *.svg`
do
convert $img $img.png
done
rename .svg.png .png *.svg.png
Offline
for img in *.svg; do
convert ${img} `basename ${img}`.png
done
Offline
The following will rename the files and give them the correct extensions. I've also removed the -define option. It doesn't seem to be necessary and was incomplete.
#!/bin/bash list=`find * -type f -name "*.svg"` for i in $list ; do convert ./scalable/apps/$i ./48x48/apps/$(basename $i .svg).png done
Snowman ftw, surely? Everyone else has ignored the output dir!
Offline
Snowman ftw, surely? Everyone else has ignored the output dir!
Nope. We simply didn't hard code a solution to one single instance; instead the code is generic enough to be easily transportable. Although, adding the functionality to query for file type to and from, plus input and output directories may be kind of cool... if one has a repeated need.
I believe that JGC's solution is the cleanest of all. Nice.
Offline
Thanks for all your help.
Arch - It's something refreshing
Offline
We simply didn't hard code a solution to one single instance; instead the code is generic enough to be easily transportable.
Hardcoded and transportable my ass! In its current state it doesn't do what was requested: specifically output to a different dir
_If_ the vars you went on to suggest had been included then I'd heartily agree...but they weren't. So there
Offline