BASH script: resize pictures in rar archive

It's tested on CentOS 7.

Before use it, you must install zip and ImageMagick:
yum install zip ImageMagick
and unrar:
# wget
# rpm -Uvh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
# yum update
# yum install unrar

Create a exectable file (it names "" here.) with Code below:
mkdir ./tmp
mkdir ./produced
for UNRARFILE in $( ls *.rar ); do
 echo item: $UNRARFILE
 mkdir ./tmp/$UNRARCACHE
 find ./tmp/$UNRARCACHE -name *.jpg -print -exec mogrify -resize x1308\> {} \;
 find ./tmp/$UNRARCACHE -name *.png -print -exec mogrify -resize x1308\> {} \;
 find . -name *.txt -exec rm -f {} \;
 find . -name *.url -exec rm -f {} \;
 cd ./tmp
 zip -0 -r ../produced/$ ./$UNRARCACHE
 cd ..
echo done\!
unset IFS

You can change resize parameter with width x height like this:
 find ./tmp/$UNRARCACHE -name *.jpg -print -exec mogrify -resize 512x1308 {} \;

or by percentage:
 find ./tmp/$UNRARCACHE -name *.jpg -print -exec mogrify -resize 50% {} \;

Execute: copy to the directory that you wanna to resize, and execute it use ". "

1. All rar archive files in directory will be resized.
2. Verify your permissions.
3. not use "./" like below when you execute it:
4. Only jpg and png will be resize.
5. It will delete *.txt and *.url in your rar archive file.
6. You must delete "tmp" manually after resizing done.


關於Dell XPS 15 (9550) / Precision 15 (5510) UHD (4K) 螢幕閃爍問題 (已解決)

How to convert GPT to MBR without delete volume

2010.08.22 微星GUS體驗會心得