zsh.li Pinkhat Memories Me About ?

Dear My
Linux

How to automatically convert the PNG pictures to JPG images.

POST_AT

On the server I have this script running in the background that converts all the PNG files I upload through SFTP to the jpg format in order to improve the website performance.

Requeriments: inotify-tools


#! /bin/bash
inotifywait -m --format '%w%f' -e close_write -r /var/www/ | while read FILE
do
	if ( echo $FILE  | grep -e png$ ); then
#	       sleep 10 
	       convert "$FILE" "${FILE%.png}.jpg"
	      mv "$FILE" /tmp
	       fi
done