Results 1 to 2 of 2

Thread: Generating thumbnails for compressed files

  1. #1
    Join Date
    Nov 2007
    Location
    Cairo, Egypt
    Beans
    121
    Distro
    Ubuntu Development Release

    Question Generating thumbnails for compressed files

    I have a pile of compressed files which contain scanned manga images. It's really hard to find the targeted file when the file names are not distinct enough.

    Is there a tool that can generate thumbnails for compressed files, basically .rar and .zip, to be displayed in file browsers namely Nautilus and/or Dolphin?

  2. #2
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Generating thumbnails for compressed files

    no idea if there is a tool for that, but i whipped up a script that uses 7zip and imagemagick

    Code:
    sudo apt-get install p7zip-full p7zip-rar imagemagick

    Code:
    #!/bin/bash
    
    h_size=200
    w_size=200
    
    types=( '*.jpg' '*.png' '*.gif' )
    
    # convert options
    conv_opt=( -define jpeg:size=$((h_size*2))x$((w_size*2)) "-[${h_size}x${w_size}]" -strip )
    
    for arch in "$@"
    do
        echo "processing $arch..."
        pics=()
        while read -r day _ _ _ _ name
        do
            [[ $day = [0-9][0-9][0-9][0-9]-* ]] || continue
            pics+=( "$name" ) 
        done < <( 7z l -r -ssc- "$arch" "${types[@]}" )
    
        th_dir=${arch}_thumb
        mkdir -p "$th_dir"
    
        for f in "${pics[@]}"
        do
            echo "generating thumbnail for \`$f'"
            fn=${f##*/}
            7z e  -so "$arch" "$f" 2>/dev/null | convert "${conv_opt[@]}"  "$th_dir"/"${fn%.*}".gif
        done
        echo
    done
    it should create a subdir with thumbnails of a defined size. I tested it on a zip file with pics and some random .cbr (=rar'ed pics) slurped off the net, but it's possible it would work with any format supported by 7z.

    when you call script, just feed it archive files to process
    Last edited by Vaphell; April 25th, 2014 at 10:52 AM.
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •