You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: image.go
    path of file: ./repos/moby/daemon/images
    
    the code of the file until where you have to start completion: package images // import "github.com/docker/docker/daemon/images"

import (
	"context"
	"encoding/json"
	"fmt"
	"io"

	"github.com/containerd/containerd/content"
	cerrdefs "github.com/containerd/containerd/errdefs"
	"github.com/co
    
func (i *ImageService) GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*image.Image, error) {
	img, err := i.getImage(ctx, refOrID, options)
	if err != nil {
		return nil, err
	}
	if options.Details {
		var size int64
		var layerMetadata map[string]string
		layerID := img.RootFS.ChainID()
		if layerID != "" {
			l, err := i.layerStore.Get(layerID)
			if err != nil {
				return nil, err
			}
			defer layer.ReleaseAndLog(i.layerStore, l)
			size = l.Size()
			layerMetadata, err = l.Metadata()
			if err != nil {
				return nil, err
			}
		}

		lastUpdated, err := i.imageStore.GetLastUpdated(img.ID())
		if err != nil {
			return nil, err
		}
		img.Details = &image.Details{
			References:  i.referenceStore.References(img.ID().Digest()),
			Size:        size,
			Metadata:    layerMetadata,
			Driver:      i.layerStore.DriverName(),
			LastUpdated: lastUpdated,
		}
	}
	return img, nil
}