A Better Way to Convert ppm to jpeg in Linux
So two months ago I posted the scripts I used to convert ppm to jpegs in my Ubuntu setup. I knew it was poorly done because it renamed every file picture.ppm.jpeg, and it needed two seperate files to work. Thanks to commenter Manuel, I finally have a much better way to do it.
ppmconv:
for pic in *.ppm
do
pnmtojpeg "${pic}" > "${pic/%ppm/jpg}"
done
Then just put that in your path somewhere, chmod +x ppmconv, and you're good to go.
To add it to your path, add this line to your ~/.bashrc file:
PATH=$PATH:"~/bin"
Then add whatever scripts you want into ~/bin to have them run. Right now the only other thing I have in there is my twitter script.
My dad and I were actually talking about this exact same solution to my problem on the way up to Davis last week, so I at least knew it was bad (Not to mention unstable...). Thank Manuel!
ppmconv:
for pic in *.ppm
do
pnmtojpeg "${pic}" > "${pic/%ppm/jpg}"
done
Then just put that in your path somewhere, chmod +x ppmconv, and you're good to go.
To add it to your path, add this line to your ~/.bashrc file:
PATH=$PATH:"~/bin"
Then add whatever scripts you want into ~/bin to have them run. Right now the only other thing I have in there is my twitter script.
My dad and I were actually talking about this exact same solution to my problem on the way up to Davis last week, so I at least knew it was bad (Not to mention unstable...). Thank Manuel!
hi
ReplyDeletethanks for posting the script - however when i try this i get the following error msg :
line 4: {pic/%ppm/jpg}: No such file or directory
can you please help me out with this?
Thanks.
Way late, but for future readers:
ReplyDeleteMake sure you don't forget the "$" before the {pic/%ppm/jpg}.
Thanks, very handy. The digicam I got stuck with gives .x-portable-pixmap as the file extension. Changing ppm to x-portable-pixmap in your script worked perfectly.
ReplyDelete