improve the js snippet that removes duplicate images to work on remote files and local files.