Fix thumbnail rewrite for png images
#2299 add script