New option for automatic image resizing

+ some improvements + refactoring in the GD department.