A good friend of mine thought about it and wrote a bash script that rips the file content and saves it to jpeg files. He payed attention that if he does a hexdump the headers for all the pps files are the same, so if you know what you're doing, theoretically, you could do this to any type of file if you know how to change the script to match the specific file type headers and separate it from the image contents.
I personally don't understand squat about what is being done in this script, but when he explains it it sounds very simple, I think it's chinese...
Here's the script code
- Code: Select all
#!/bin/bash
# Rip image files from PPS files
# By Eldad Zack
for fn in "$@"
do
echo Ripping ${fn} ...
declare -a pos
posindex=0
poslist=$(hexdump -v -e '1/1 "%02x"' "${fn}" |
sed 's/.ffd8ffe00010/\nMARKERMARKER/g' |
grep -abo MARKERMARKER |
cut -f1 -d':');
for x in $poslist
do
((posindex++))
((y=x/2))
pos[$posindex]=${y}
done
pos[$((posindex+1))]=$(stat -c '%s' "${fn}")
for ((x=1; x<$posindex; x++))
do
echo " pos $x ${pos[$x]} to ${pos[$((x+1))]}"
#count=$((${pos[$((x+1))]}-${pos[$x]}))
count=$((${pos[$posindex]}-${pos[$x]}))
fnum=$(printf "%04g" $x);
dd if="${fn}" ibs=1 skip=${pos[$x]} count=$count 2>/dev/null | convert - "${fn}.$fnum.jpg"
if [[ $(stat -c %s "${fn}.$fnum.jpg") == 0 ]];
then
echo "[size zero] rm ${fn}.$fnum.jpg"
rm ${fn}.$fnum.jpg
fi
done
echo " + $(ls "${fn}"*jpg | wc -l | sed 's/ \+//g') files ripped."
#ffd8ffe000104a464946 JFIF
done
Copy/Paste the code, save the file as ppsrip.sh then make executable
- Code: Select all
chmod a+x ppsrip.sh
How does it work? You just run it from command line. If you have a file named "Landscapes.pps" you just type
[code]
./ppsrip.sh Landscapes.pps
[code]
Let's say this file has 10 images within, then you end up with 10 jpeg files named Landscapes.pps.0001.jpg, Landscapes.pps.0002.jpg and so on.
I find this very useful so I wanted to share it with you.
Thanks to my friend Eldad Zack!
Ziv