Are you a spammer

Please note, that the first 3 posts you make, will need to be approved by a forum Administrator or Moderator before they are publicly viewable.
Each application to join this forum is checked at the Stop Forum Spam website. If the email or IP address appears there when checked, you will not be allowed to join this forum.
If you get past this check and post spam on this forum, your posts will be immediately deleted and your account inactivated.You will then be banned and your IP will be submitted to your ISP, notifying them of your spamming. So your spam links will only be seen for an hour or two at most. In other words, don't waste your time and ours.

This forum is for the use and enjoyment of the members and visitors looking to learn about and share information regarding the topics listed. It is not a free-for-all advertising venue. Your time would be better spent pursuing legitimate avenues of promoting your websites.

HOWTO: Rip images from PPT/PPS files (bash script)

Post your How to's here


HOWTO: Rip images from PPT/PPS files (bash script)

Postby tuxsax » Sat Nov 01, 2008 3:20 pm

I don't know how about you, but I get a lot of nice mails with Powerpoint attachments, many of them have pictures that worth saving them separately and it's a bit tedious to do it one by one.
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
______________________________
Two things I love: Linux and my sax
tuxsax
U.E. Master
U.E. Master
 
Posts: 790
Joined: Sat Apr 26, 2008 4:15 am
Age: 53
Operating System: Ultimate Edition Beta Tester

Return to How To's (Do not post questions please)

Who is online

Users browsing this forum: No registered users and 12 guests