Helper function for simple image manipulation using GD functions