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: cache.go
    path of file: ./repos/photoprism/internal/crop
    
    the code of the file until where you have to start completion: package crop

import (
	"fmt"
	"path/filepath"

	"path"

	"github.com/photoprism/photoprism/pkg/clean"
	"github.com/photoprism/photoprism/pkg/fs"
)

// FromCache returns the crop file name if cached.
func FromCache(hash, area string, size Size, thumbPath string) (fileName string, err error) {
	fileName, err = FileName(hash, area, size.Width, size.Height, thumbPath)

	if err != nil {
		return fileName, err
	}
    
func FileName(hash, area string, width, height int, thumbPath string) (fileName string, err error) {
	if len(hash) < 4 {
		return "", fmt.Errorf("crop: invalid file hash %s", clean.Log(hash))
	}

	if len(thumbPath) < 1 {
		return "", fmt.Errorf("crop: cache path missing")
	}

	if width < 1 || height < 1 || width > 2048 || height > 2048 {
		return "", fmt.Errorf("crop: invalid size %dx%d", width, height)
	}

	fileName = path.Join(thumbPath, hash[0:1], hash[1:2], hash[2:3], fmt.Sprintf("%s_%dx%d_crop_%s%s", hash, width, height, area, fs.ExtJPEG))

	return fileName, nil
}