Sunday, April 29, 2012

Resizing Images from the Command Line

I love the power of the Linux command line. I am working on resizing images and I was able to resize only the ones I wanted with a few commands. Here is what I came up with:
    
# Get only the files with a vertical or horizontal resolution of 4320px;
# the output is the file name followed by the resolution:
find . -name "*.JPG" -exec identify -format "%d/%f %wx%h" {} \; | grep 4320 > files.txt

# Get just the file name:
awk -F ' ' '{ print $1 }' < files.txt > files2resize.txt

# Resize the photos:
for i in `cat files2resize.txt`; do 
    mogrify -verbose -resize '2816x2816>' "$i"; 
done

Friday, April 27, 2012

SSH Match Errors

I could not start ssh after adding the following lines to my sshd_config:
Match Address 192.168.0.0/24 
GatewayPorts yes
The only clue are the following lines from syslog:
Apr 26 21:03:11 desktop kernel: [264746.428869] init: ssh main process (8486) terminated with status 255
Apr 26 21:03:11 desktop kernel: [264746.428942] init: ssh main process ended, respawning
Apr 26 21:03:11 desktop kernel: [264746.437024] init: ssh main process (8489) terminated with status 255
Apr 26 21:03:11 desktop kernel: [264746.437099] init: ssh main process ended, respawning
Apr 26 21:03:11 desktop kernel: [264746.446559] init: ssh main process (8492) terminated with status 255
Apr 26 21:03:11 desktop kernel: [264746.446627] init: ssh respawning too fast, stopped
After searching Google I found this bug report.
The final entry gave the solution in my case, the Match directive must come after the Subsystem directive. After moving things around, everything began to work again.