added orientation checking for use with imagerotate from GD (or similar)
bugfix