in reply to tr not working

It might very well be an issue with a wrong character encoding. If $img is a decoded string, you also have to use utf8; to make perl also decode your tr/// code.