ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm setting up icewm to use on a laptop and would like to use some of the KDE 16x16 icons, but they need to be changed from .png to .xpm and renamed so that they end in "_16x16".
I can do this one file at a time using ImageMagick from the command line as follows:
>convert filename.png filename_16x16.xpm
but, when I try adapting some of the script examples (not specifically for this) I found searching this sight and googling, I cant get it to work. I'm just a little too noobish with scripting and variables.
erm i'm not sure if renaming will address the issue of the file format needing to change...
If you do perl yould use the ImageMagick module for perl and in general the psuedo code for that would be
opendir (DIR, /usr/share/kde/icons);
while <DIR> {
Imagemagick::convert shift
save
}
closedir
or something close to that...haven't used image maick in a long while
Technomage1 - I haven't tried your suggestion yet. But, I have another question for you. If I were to use The Gimp, is ther a way to perform batch file converions from within the program like in paintshop pro and other programs, and then use quatsch's suggestion for batch renaming?
What about somethign like this - sorry I haven't had time to test it properly:
Code:
#!/bin/bash
# Pass the dir to look in as the first argument
for file in `find $1 -name *.png`; do
name=`echo $file | sed 's/\.png/_16x16\.xpm/'`
convert $file $name
done
Thanks for the scripting suggestions. I'm going to try them tonight.
I have one other question for any of you. After looking further into it, it appears that there is no way for Gimp to do this. You can do some perl scripting provided you have gimpperl installed, however I upgraded to 1.3.x and since its GTK2 base and the perl libs are GTK 1.2 based - well perl is out of the question and I'm back to ImageMagick and convert.
So my question is this. When I did the following - >convert *.png *.xpm I hosed all the file names (I tested on a test file ) getting xxx.xpm.1 through xxx.xpm.125 with xxx not having any relation to the original file name. David, will your script preserve the names at all?
The script I suggested should convert images one at a time the convert command would be:
convert /path/to/picture_of_me.png /path/to/picture_of_me_16x16.xpm
So it will keep the first part of the filename the same.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.