Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm using Skype on Linux.

Where can I find images cached by skype of my contact's avatars?

share|improve this question
    
I don't have Linux on my laptop right now to verify, but you check the ~/.Skype directory contents. –  kartikmohta Jan 15 '10 at 2:33

3 Answers 3

up vote 5 down vote accepted

I wanted to get those Skype avatars too so I used whitequark's answer to make a little bash script which does just that. Here it is:

#!/bin/bash

if [ \( $# -lt 1 \) ];
then
  echo "Usage: $0 folder";
  echo "Where folder is of the form /home/username/.Skype/username";
  exit;
fi;

for i in `ls $1`;
do
  if [ -f $1/$i ];
  then
    #echo "i: $i";
    filedump=`hexdump -v -e '"" 1/1 "%02x" ""' $1/$i | sed -e 's/ffd8ffe0/\nffd8ffe0/g'`;
    nocc=`echo "$filedump" | wc -l`; # occurences of the \n char. Means that there are nocc-1 occurences of our word
    #echo "nocc: $nocc";
    if [ "$nocc" -ge 2 ];
    then
      k=0;
      old_IFS=$IFS; #field separator
      IFS=$'\n';
      offset=0;
      for j in $filedump;
      do
        w=`echo $j | wc -m`; # gives actually lettercount+1
        w=$[w-1];
        offset=$[offset+w];
        #echo "offset: $offset";
        filename1="${i}_${k}_notclean.jpg";
        filename2="${i}_${k}.jpg";
        dd ibs=1 if=$1/$i of=$filename1 skip=`echo "$offset/2" | bc` status=noxfer;
        if [ `du $filename1 | cut -f1` -gt 0 ];
        then
          convert $filename1 $filename2; #convert is actually only used to remove the data after the image
        fi;
        rm $filename1;
        k=$[k+1];
      done;
      IFS=$old_IFS;
    fi;
  fi;
done
share|improve this answer
    
This does not always work, there are some avatars that are not found and it extracts some broken images. See my answer for a cleaner solution. –  Guillaume Brunerie Nov 4 '12 at 1:44

This Skype forum thread is about avatars: http://forum.skype.com/index.php?showtopic=99471.

  • First, they discuss some commands that allow you saving avatars from Skype cache with it public interface through it doesn't apparently work on Linux. I don't know if they fixed that interface already, and that's not what your question is about.
  • Second, one Skype dev said that all images are stored in JPEG format and provide a header in hex (JFIF). grep'ing hexdump of all Skype files with the for i in *; do echo $i; hd $i | grep 'ff d8 ff e0'; done command revealed many occurences of this header in .Skype/userNNN.dbb files where NNN is some number. This files have some absolutely undocumented, proprietary format and are probably keeping all cached information about users; you can extract avatars themselves by scanning for header and then copying everything until end of file to other file. All image viewers will skip any data after the image itself (a technology RARJPG is based on), and if you want to remove junk out of them you can "modify" it without modifying e.g. with imagemagick and command convert file.jpg file_clean.jpg. ImageMagick behaves as described viewer: it reads image, skips anything that follow it and then writes only image itself.
share|improve this answer

Here is a much cleaner script extracting both low-def and high-def avatars from the main.db file and saving them to files named after the corresponding Skype usernames.

You will need sqlite3 and xxd to run this script.

The content of the main.db database is fairly easy to understand, with a bit of imagination there is a lot more that could be extracted from it.

#!/bin/bash

if (( $# != 1 ))
then
    echo "Usage: $0 folder"
    echo "Where folder is of the form /home/username/.Skype/username"
    exit 1
fi

# Magic string used at the beginning of JPEG files
magic=FFD8FFE0

# We read main.db and extract the Skype name, the avatar image and the
# attachments (which often contain a high-def version of the avatar image)
sqlite3 "$1/main.db" "select skypename,hex(avatar_image),hex(profile_attachments) from Contacts;" |\
while read line
do
    IFS='|'
    # We convert the line into an array
    a=($line)
    if [[ -n ${a[1]} ]]  # There is an avatar_image
    then
        # We strip everything before the magic string, convert it back to binary, and save it to a file
        echo $magic${a[1]#*$magic} | xxd -r -p > ${a[0]}_small.jpg
    fi
    if [[ -n ${a[2]} ]]  # There is a profile_attachments
    then
        # Same as above
        echo $magic${a[2]#*$magic} | xxd -r -p > ${a[0]}.jpg
    fi
done
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.