O script inotifywait que você tinha estava usando -e create
em vez de -e close_write
; a diferença é que o evento create será disparado antes que os dados tenham sido gravados no arquivo; assim, cwebp
tinha "0 bytes de dados do arquivo".
Na página inotifywait que você referenciou:
- create
A file or directory was created within a watched directory.
- close_write
A watched file or a file within a watched directory was closed, after being opened in writeable mode. This does not necessarily imply the file was written to.