GRAPHICS: Allow abitrary input sizes for thumbnail scaling.

Instead of a fixed 1/2 or 1/4 scaling we do a two step scaling now:
1) Scale image to width < 160*2 && height < [100,120]*2 with 1/4 or 1/2
   nearest-neighbor.
2) Use a bilinear scaler to scale aspect preserving to 160x[100,120]

This fixes bug #3614568 "GRAPHICS: Odd thumbnail sizes crash".

This is a completely hacked up implementation based on some old code from 2011. Any feedback is appreciated.