Fix division by 0 in case a thumbnail has a width or height equal to 0
Merge pull request #840 from romainneutron/width-height

[3.8] Fix division by 0 in case a thumbnail has a width or height equal to 0