Forums » Linux
Ok, this is a tga to png script, as far as I can tell, it works well, good enough:
requirements:
wpng (part of libpng package in 1.2.x and 1.0.15)
netbpm (includes tgatoppm)
the script itself:
---------------------------------------------------------
#! /bin/sh
file="$*"
tgatoppm $file.tga > $file.ppm
wpng -gamma 1.1 $file.ppm
echo Created $file.png
rm $file.ppm
mv $file.png ./pngs/$file.png
echo Done.
----------------------------------------------------------
save this as a text file named "makepng" or something.
Then all you do is:
cd .vendetta (or where your tgas are)
make a folder named pngs where your screenshots are located (so things can be sorted easier)
makepng filename
then it'll create a filename.png picture ;)
you can modify that script all you want.
requirements:
wpng (part of libpng package in 1.2.x and 1.0.15)
netbpm (includes tgatoppm)
the script itself:
---------------------------------------------------------
#! /bin/sh
file="$*"
tgatoppm $file.tga > $file.ppm
wpng -gamma 1.1 $file.ppm
echo Created $file.png
rm $file.ppm
mv $file.png ./pngs/$file.png
echo Done.
----------------------------------------------------------
save this as a text file named "makepng" or something.
Then all you do is:
cd .vendetta (or where your tgas are)
make a folder named pngs where your screenshots are located (so things can be sorted easier)
makepng filename
then it'll create a filename.png picture ;)
you can modify that script all you want.
JPEG version ("w00t: -Roguelazer):
does not require libpng, just netbpm
----------------------------------------------------
#! /bin/sh
file="$*"
tgatoppm $file.tga > $file.ppm
ppmtojpeg $file.ppm > $file.jpeg
echo Created $file.jpeg
rm $file.ppm
mv $file.jpeg ./jpegs/$file.jpeg
echo Done.
----------------------------------------------------
name it makejpeg or something :)
does not require libpng, just netbpm
----------------------------------------------------
#! /bin/sh
file="$*"
tgatoppm $file.tga > $file.ppm
ppmtojpeg $file.ppm > $file.jpeg
echo Created $file.jpeg
rm $file.ppm
mv $file.jpeg ./jpegs/$file.jpeg
echo Done.
----------------------------------------------------
name it makejpeg or something :)
Now, if I type "makejpeg *", will it work? What if I run the script on some other type of file? How about if I rename a text file textfile.tga? Will it work? What would the pic look like? How many stupid questions can I think of?
no, makejpeg * will not work. don't even try it.
you have to do makejpeg dump0000 wait, press up arrow, change the last 0 to 1, etc etc.
The pics look like normal compressed jpegs.
you have to do makejpeg dump0000 wait, press up arrow, change the last 0 to 1, etc etc.
The pics look like normal compressed jpegs.
New, IMPROVED version for making tga to png, same requirements as before.. BUT it includes a safe system that won't even try to proceed if file isn't found:
-----------------------------------------------------------
#! /bin/sh
file="$*"
ls $file.tga
if [ "$?" = "0" ]; then
echo found file moving on...
else
echo could not find file. Exiting.
exit 0
fi
tgatoppm $file.tga > $file.ppm
ls $file.ppm
if [ "$?" = "0" ]; then
echo found file moving on...
else
echo tga to ppm conversion failed. Exiting.
exit 0
fi
wpng -gamma 1.1 $file.ppm
ls $file.png
if [ "$?" = "0" ]; then
echo created $file.png
else
echo ppm to png conversion failed. Exiting.
exit 0
fi
mv $file.ppm ./ppms/$file.ppm
mv $file.png ./pngs/$file.png
echo Done.
-------------------------------------------------------------
I'm adjusting it for jpeg now but to also get it through testing, it might not be ready for tonight.
-----------------------------------------------------------
#! /bin/sh
file="$*"
ls $file.tga
if [ "$?" = "0" ]; then
echo found file moving on...
else
echo could not find file. Exiting.
exit 0
fi
tgatoppm $file.tga > $file.ppm
ls $file.ppm
if [ "$?" = "0" ]; then
echo found file moving on...
else
echo tga to ppm conversion failed. Exiting.
exit 0
fi
wpng -gamma 1.1 $file.ppm
ls $file.png
if [ "$?" = "0" ]; then
echo created $file.png
else
echo ppm to png conversion failed. Exiting.
exit 0
fi
mv $file.ppm ./ppms/$file.ppm
mv $file.png ./pngs/$file.png
echo Done.
-------------------------------------------------------------
I'm adjusting it for jpeg now but to also get it through testing, it might not be ready for tonight.
Ok, JPEG version is ready enough... ready for testing:
---------------------------------------
#! /bin/sh
file="$*"
ls $file.tga
if [ "$?" = "0" ]; then
echo found file moving on...
else
echo could not find file. Exiting.
exit 0
fi
tgatoppm $file.tga > $file.ppm
ls $file.ppm
if [ "$?" = "0" ]; then
echo found file moving on...
else
echo tga to ppm conversion failed. Exiting.
exit 0
fi
ppmtojpeg $file.ppm > $file.jpeg
ls $file.jpeg
if [ "$?" = "0" ]; then
echo created $file.jpeg
else
echo ppm to jpeg conversion failed. Exiting.
exit 0
fi
mv $file.ppm ./ppms/$file.jpg
mv $file.jpeg ./jpegs/$file.jpeg
echo Done.
------------------------------------------------
---------------------------------------
#! /bin/sh
file="$*"
ls $file.tga
if [ "$?" = "0" ]; then
echo found file moving on...
else
echo could not find file. Exiting.
exit 0
fi
tgatoppm $file.tga > $file.ppm
ls $file.ppm
if [ "$?" = "0" ]; then
echo found file moving on...
else
echo tga to ppm conversion failed. Exiting.
exit 0
fi
ppmtojpeg $file.ppm > $file.jpeg
ls $file.jpeg
if [ "$?" = "0" ]; then
echo created $file.jpeg
else
echo ppm to jpeg conversion failed. Exiting.
exit 0
fi
mv $file.ppm ./ppms/$file.jpg
mv $file.jpeg ./jpegs/$file.jpeg
echo Done.
------------------------------------------------
Suggestion: Install "ImageMagick" (yep, with ck). Then you get a convenient "convert" command.
To convert every file with a .tga extension use this small script:
for f in *.tga ; do convert "$f" "$(basename "$f" .tga).jpg" ; done
Neat trick: basename will strip the paths from the files. So if you run this script in a different directory and use path/to/tga/*.tga in the argument to the for-loop, then the jpegs will be created in the different directory.
L00s3rs would of course just but a path between " and $(basename... ahem :-)
And since convert is smart about the files, you can even run it on anything and it will figure out what to do (print an error if its a text, for example).
To convert every file with a .tga extension use this small script:
for f in *.tga ; do convert "$f" "$(basename "$f" .tga).jpg" ; done
Neat trick: basename will strip the paths from the files. So if you run this script in a different directory and use path/to/tga/*.tga in the argument to the for-loop, then the jpegs will be created in the different directory.
L00s3rs would of course just but a path between " and $(basename... ahem :-)
And since convert is smart about the files, you can even run it on anything and it will figure out what to do (print an error if its a text, for example).
yeah, I already looked into ImageMagick, didn't like it.
I don't claim my script is better, but it works for me.
#!/bin/bash
#
# Convert TrueVision Targa file (tga) snapshots to jpeg /Birre
umask 22
for i in *.tga
do
snap=`basename $i .tga`
tgatoppm $i | ppmtojpeg > $snap.jpg 2>/dev/null && rm -f $i
done
<http://norsborg.net/vendetta/tga2jpg>
/Birre
#!/bin/bash
#
# Convert TrueVision Targa file (tga) snapshots to jpeg /Birre
umask 22
for i in *.tga
do
snap=`basename $i .tga`
tgatoppm $i | ppmtojpeg > $snap.jpg 2>/dev/null && rm -f $i
done
<http://norsborg.net/vendetta/tga2jpg>
/Birre
convert is slower than Blaster's implimentation. I tested them both on the same computer, his is faster. However, convert is more user-friendly.
roguelazer, it is? heh, never compared side by side.
sillies, GIMP likes to munch on TGA just fine, thank you...
:<=> (munchmunch)
:<=> (munchmunch)
'cept the internet doesn't, and the gimp takes a loooong time to load.
Does it... tell me rogue... what comp are u using?
Um. My linux desktop. Why?
GIMP takes about 5 seconds just to load... sooo ;)
Yeah - i meant the s-p-e-e-d of it... My old (very beaten) comp do it in 10 - 15 secs... ;)
5 secs? A lot more than that for me. Extension script-fu or something like that takes 15 secs all by its lonesome.
Bump: I made up a little scriptie... It changed my .vendetta directory from 985M to 67M:
#!/bin/bash
for f in *.tga
do convert "$f" "$(basename "$f" .tga).jpg"
done
for f in *.tga
do rm -f "$f"
done
Only took about 15 minutes to process all 350+ screenshots.
#!/bin/bash
for f in *.tga
do convert "$f" "$(basename "$f" .tga).jpg"
done
for f in *.tga
do rm -f "$f"
done
Only took about 15 minutes to process all 350+ screenshots.
convert, ok.
well... what happens like if... it didn't covert right to .jpg, you delete .tga immediately after.
well... what happens like if... it didn't covert right to .jpg, you delete .tga immediately after.