1. If you have a problem and need help, create a new thread with a title that briefly describes the problem.
    Do not use titles like 'Help!' or 'I have a problem!'
    Dismiss Notice
  2. Hey Guest, is it this your first time on the forums?

    Visit the Beginner's Box

    Introduce yourself, read some of the ins and outs of the community, access to useful links and information.

    Dismiss Notice

Screenshot repair script for Linux/Mac

Discussion in 'General Help' started by zninja, Feb 17, 2012.

  1. zninja

    zninja Shopkeep Stealer

    Messages:
    47
    The screenshots captured in Linux and Mac builds have blue and red channels swapped, which makes the images look blue. I wrote a small bash script which detects bad screenshots and fixes them. Just execute the script in the 'Screenshots' folder. Also, you need to have imagemagick installed.
    Code:
    #!/bin/sh
    # find handles errors better than simple wildcard
    files=`find . -maxdepth 1 -type f -name 'screen-??-??-??-??-??-??.png'`
    if [ -z "$files" ]; then
          echo "No screenshots to repair"
          exit
    fi
    echo "Processing..."
    for img in $files; do
          # c1: Dark blue pixel in the health bar (should be gray/brown)
          # c2: Orange pixel in the score table (should be red)
          c1=`convert $img -format "%[pixel: u.p{10,10}]" info:`
          c2=`convert $img -format "%[pixel: u.p{50,150}]" info:`
          if [ "$c1" = "rgb(96,113,100)" -o "$c2" = "rgb(171,133,29)" ]; then
                echo "$img"
                convert "$img" -separate -swap 0,2 -combine "$img"
          fi
          # Rename the file so it won't be checked again when this script is used in the future
          mv "$img" "fixed-`basename $img`"
    done
    echo "Done"
    
    The bug might get fixed before zombies arrive but I'm posting this anyway. Enjoy :)

    Changelog:
    Code:
    17.2.2012: Initial version
    18.2.2012: Changed c1 coordinates from (15,15) to (10,10). Should work for both HUD sizes.
    20.2.2012: Added comments + processed files get renamed
    
     
  2. trelawney

    trelawney KAG Guard Tester

    Messages:
    771
    It works great in Linux (Debian 6.0.4) , thanks for the script zninja.
    Before:
    before.png
    After:
    screen-12-02-17-23-34-43.png
     
  3. Deck

    Deck Catapult Fodder

    Messages:
    19
    Doesn't work.
    Code:
    deck@archdck:~/KAG/Screenshots$ uname -a
    Linux archdck 2.6.32-37-generic #81-Ubuntu SMP Fri Dec 2 20:35:14 UTC 2011 i686 GNU/Linux
    
    Writes "done", tho
     
  4. trelawney

    trelawney KAG Guard Tester

    Messages:
    771
    did you install imagemagick? Also make sure you run the script while your pwd is /Screenshots
     
  5. Deck

    Deck Catapult Fodder

    Messages:
    19
    Yes, its installed
    Code:
    deck@archdck:~$ sudo aptitude search imagemagick
    p  graphicsmagick-imagemagick-compat  - image processing tools providing ImageMagick i
    i  imagemagick                        - image manipulation programs               
    p  imagemagick-dbg                    - debugging symbols for ImageMagick         
    p  imagemagick-doc                    - document files of ImageMagick        
    And yes, i run it from KAG/Screenshots folder (you can se it on my previous log)
    Moreover, if i hadn't had imagemagick it would have written: "convert: command not found" but it's ok
     
  6. zninja

    zninja Shopkeep Stealer

    Messages:
    47
    The script checks only 2 pixels so it isn't 100% accurate. Some images might be left untouched. If that is not the case, then you might have an older/newer version of imagemagick which doesn't work as expected. Does it work if you try to convert an image manually?
    Code:
     convert <INPUT> -separate -swap 0,2 -combine <OUTPUT> 
     
  7. Deck

    Deck Catapult Fodder

    Messages:
    19
    Yes. it works if i run it manually. Strangely..
     
  8. zninja

    zninja Shopkeep Stealer

    Messages:
    47
    BTW this thread doesn't need to be a sticky since the bug is fixed.
     
    Downburst likes this.