func LoadImage(file string) (image.Image, *image.Config, error) {
	f, err := os.Open(file)
	if err != nil {
		return nil, nil, err
	}
	r := bufio.NewReader(f)
	data, err := ioutil.ReadAll(r)
	f.Close()
	cfg := image.Config{}
	cfg, _, err = image.DecodeConfig(bytes.NewReader(data))
	if err != nil {
		f.Close()
		return nil, nil, err
	}
	img, _, err := image.Decode(bytes.NewReader(data))
	if err != nil {
		f.Close()
		return nil, nil, err
	}
	return img, &cfg, nil
}
LoadImage loads an image from a file
package maps
import (
	"bufio"
	"bytes"
	"image"
	"image/draw"
	"image/jpeg"
	"image/png"
	"io/ioutil"
	"os"
	"github.com/ryankurte/go-mapbox/lib/base"
)
func LocationToTileID(loc base.Location, level uint64) (uint64, uint64) {
	return MercatorLocationToTileID(loc.Latitude, loc.Longitude, level, 256)
}
func TileIDToLocation(x, y float64, level uint64) base.Location {
	lat, lng := MercatorPixelToLocation(x, y, level, 256)
	return base.Location{
		Latitude:  lat,
		Longitude: lng,
	}
}
func WrapTileID(x, y, level uint64) (uint64, uint64) {
	x = x % (2 << (level - 1))
	y = y % (2 << (level - 1))
	return x, y
}
func GetEnclosingTileIDs(a, b base.Location, level uint64) (uint64, uint64, uint64, uint64) {
	aX, aY := LocationToTileID(a, level)
	bX, bY := LocationToTileID(b, level)
	var xStart, xEnd, yStart, yEnd uint64
	if bX >= aX {
		xStart = aX
		xEnd = bX
	} else {
		xStart = bX
		xEnd = aX
	}
	if bY >= aY {
		yStart = aY
		yEnd = bY
	} else {
		yStart = bY
		yEnd = aY
	}
	return xStart, yStart, xEnd, yEnd
}
func StitchTiles(images [][]Tile) Tile {
	imgX := images[0][0].Image.Bounds().Dx()
	imgY := images[0][0].Image.Bounds().Dy()
	xSize := imgX * len(images[0])
	ySize := imgY * len(images)
	stitched := image.NewRGBA(image.Rect(0, 0, xSize, ySize))
	for y, row := range images {
		for x, img := range row {
			sp := image.Point{0, 0}
			bounds := image.Rect(x*imgX, y*imgY, (x+1)*imgX, (y+1)*imgY)
			draw.Draw(stitched, bounds, img, sp, draw.Over)
		}
	}
	return NewTile(images[0][0].X, images[0][0].Y, images[0][0].Level, images[0][0].Size, stitched)
}