I used gsettings set org.gnome.desktop.background picture-uri 'file://PathToImage'
to set an image as a wallpaper as suggested in this answer. This does not do the job properly. For today's bing image, script here changes my background like this
This happens at random and sometimes it sets the wallpaper properly. Using GUI, setting the image as wallpaper by right-clicking on it works properly every time. Any possible causes of this problem?
Edit1: The download is perfectly fine. As I have mentioned, I can set the photo as wallpaper by right clicking the photo and chosing 'set as wallpaper' from the menu.
rm /home/$USER/.cache/wallpaper/*
before executing script. Let me know if it work.