Do not rely on path to detect image optimization

Because the path technics does not support symbolic links.

Signed-off-by: Clement Escoffier <clement.escoffier@gmail.com>