Documentation
¶
Index ¶
- Constants
- func CompareImgFormFolders(inputDir, outputDir string) []string
- func DecImg(r io.Reader) (image.Image, error)
- func EncImg(w io.Writer, img image.Image, format ImageFormat, compressionLevel ...SetClv) error
- func GetLastFolderName(path string) string
- func GetOpaqueBounds(img image.Image, tolerance uint8) image.Rectangle
- func ListFilePaths(dirPath string) ([]string, error)
- func LoadImg(pathName string) (image.Image, error)
- func MaxInt(a, b int) int
- func MinInt(a, b int) int
- func NaturalLess(a, b string) bool
- func NaturalSort(items []string)
- func Parallel(start, stop int, fn func(<-chan int))
- func Rotate180(img image.Image) *image.NRGBA
- func Rotate270(img image.Image) *image.NRGBA
- func Rotate90(img image.Image) *image.NRGBA
- func SafeCreate(outputPath string) (*os.File, error)
- func SaveImgAutoExt(pathNoneExt string, img image.Image, format ImageFormat, ...) error
- func SaveImgByExt(outputPath string, img image.Image, compressionLevel ...SetClv) error
- type ImageFormat
- type SameDetectInfo
- type SetClv
Constants ¶
const ( NoCompression clv = 0 // No compression BestSpeed clv = 1 // Best speed DefaultCompression clv = 2 // Default compression BestCompression clv = 3 // Best compression )
Variables ¶
This section is empty.
Functions ¶
func CompareImgFormFolders ¶
func EncImg ¶
EncImg encodes the image to the specified format and writes it to the writer. Parameters:
- w: the writer to write the encoded image
- img: the image to encode
- format: the image format to encode
- compressionLevel: the compression level to use, default is NoCompression
Returns:
- error: an error if the format is unsupported or if encoding fails
Supported formats:
- JPEG
- PNG
- TIFF
- BMP
- WEBP
func GetLastFolderName ¶
GetLastFolderName
Parameters:
- path: the path
Returns:
- string: the last folder name
Example:
folderName := GetLastFolderName("./sprites/atlas/a.png")
// folderName = "atlas"
func GetOpaqueBounds ¶
GetOpaqueBounds returns the bounds of the opaque area of the image. The image is assumed to be in RGBA format.
func ListFilePaths ¶
ListFilePaths
Parameters:
- dirPath: the directory path
Returns:
- []string: the file paths
- error: the error
Example:
filePaths, err := ListFilePaths("./sprites")
func NaturalLess ¶
func Rotate180 ¶
Rotate180 rotates the image 180 degrees counter-clockwise and returns the transformed image.
func Rotate270 ¶
Rotate270 rotates the image 270 degrees counter-clockwise and returns the transformed image.
func Rotate90 ¶
Rotate90 rotates the image 90 degrees counter-clockwise and returns the transformed image.
func SaveImgAutoExt ¶
Types ¶
type SameDetectInfo ¶
type SameDetectInfo struct {
//ccc.png -> aaa.png
//bbb.png -> aaa.png
DupeToBaseName map[string]string
//aaa.png -> [ccc.png, bbb.png]
BaseToDupesName map[string][]string
}
func FindDuplicateFiles ¶
func FindDuplicateFiles(filePaths []string) ([]string, SameDetectInfo, error)
FindDuplicateFiles finds duplicate files in the given file paths.
Parameters:
- filePaths: the paths of the files to be checked
Returns:
- []string: the paths of the unique files
- map[string]string: the map of duplicate file names and their corresponding base names
- map[string][]string: the map of base file names to their duplicate file names
- error