Browse Source

utils: rewrite resize-cover script with python for performance

remotes/origin/cmake
Romain Goffe 13 years ago
parent
commit
9a963b037e
  1. 2
      utils/release.sh
  2. 21
      utils/resize-cover.py
  3. 17
      utils/resize-cover.sh

2
utils/release.sh

@ -49,7 +49,7 @@ fi;
#echo "emacs batch indentation done !"
./utils/rules.py
./utils/typo.sh ./songs/*/*.sg
./utils/resize-cover.sh
./utils/resize-cover.py
#build all songbooks
rm -f *.d

21
utils/resize-cover.py

@ -0,0 +1,21 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#Author: Romain Goffe
#Date: 28/12/2011
#Description: Resize all covers to 128,128 thumbnails
import Image
import glob
width = 128
height = 128
# Process song files
covers = glob.glob('songs/*/*.jpg')
for filename in covers:
source = Image.open(filename)
if source.size > (128, 128):
print "resizing : " + filename
target = source.resize((width, height), Image.ANTIALIAS)
target.save(filename)

17
utils/resize-cover.sh

@ -1,17 +0,0 @@
#!/bin/sh
# Resize image if needed
for image in songs/*/*.jpg songs/*/*.png ;
do
SIZE=`identify $image | awk '{ print $3}' | sed 's/x/ /'`;
XSIZE=`echo $SIZE | awk '{ print $1}'`;
YSIZE=`echo $SIZE | awk '{ print $2}'`;
if [ $((XSIZE)) -gt 128 ]
then
convert $image -resize 128x128 $image;
elif [ $((YSIZE)) -gt 128 ]
then
convert $image -resize 128x128 $image;
fi
done;
Loading…
Cancel
Save