Trevor Appleton has released his script that will take a folder of images, convert any images it finds into JPG, delete the original and then resize the new image to a fixed width. This is something you could quite easily run on a Pi. Read how to do it here.
[…] Michael Horne Trevor Appleton has released his script that will take a folder of images, convert any images it […]
This can be done with a one liner in bash (it can be made even smaller by removing the echo statements). Here is the complete script and below is the same script in a one-liner.
Note you would have to install imagemagick for the convert command but that is a massively useful thing to have anyway – sudo apt-get install imagemagick.
The converted files are placed in the directory resized.
[code]
mkdir -p resized
ls | while read line; do
echo Processing $line
a=$(file $line | grep “image data” | wc -l)
if [ “$a” = “1” ]; then
echo $line is an image, converting to jpeg and resizing
convert “$line” -resize 1024x “resized/$line.jpg”
else
echo $line is not an image file, ignoring
fi
done
[/code]
or as a one-liner:
[code]
mkdir -p resized; ls | while read line; do echo Processing $line; a=$(file $line | grep “image data” | wc -l); if [ “$a” = “1” ]; then echo $line is an image, converting to jpeg and resizing; convert “$line” -resize 1024x “resized/$line.jpg”; else echo $line is not an image file, ignoring; fi; done
[/code]