Format and tidy up
This commit is contained in:
parent
207b54730f
commit
b5319c48b9
|
@ -48,7 +48,7 @@ func MakeReadMe(imageList []string, imgDs map[string][]images.Details) {
|
|||
|
||||
for _, imageName := range imageList {
|
||||
txt += "## " + imageName + "\n\n"
|
||||
txt += fmt.Sprintf("![Original %s image](%s)\n\n", imageName, common.ImageDir + imageName + ".jpg")
|
||||
txt += fmt.Sprintf("![Original %s image](%s)\n\n", imageName, common.ImageDir+imageName+".jpg")
|
||||
|
||||
txt += "| Image | Properties | Size (px^2) | Image Quality (%) | Size (bytes) |\n"
|
||||
txt += "| :---: | ---------- | ----------: | ----------------: | -----------: |\n"
|
||||
|
|
|
@ -9,6 +9,10 @@ import (
|
|||
"github.com/oliamb/cutter"
|
||||
)
|
||||
|
||||
func ResizeSquare(size uint, img image.Image) image.Image {
|
||||
return resize.Resize(size, 0, img, resize.Bilinear)
|
||||
}
|
||||
|
||||
func Crop(img image.Image) image.Image {
|
||||
var sl int
|
||||
if img.Bounds().Max.X > img.Bounds().Max.Y {
|
||||
|
@ -18,9 +22,9 @@ func Crop(img image.Image) image.Image {
|
|||
}
|
||||
|
||||
croppedImg, err := cutter.Crop(img, cutter.Config{
|
||||
Width: sl,
|
||||
Width: sl,
|
||||
Height: sl,
|
||||
Mode: cutter.Centered,
|
||||
Mode: cutter.Centered,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -29,10 +33,6 @@ func Crop(img image.Image) image.Image {
|
|||
return croppedImg
|
||||
}
|
||||
|
||||
func ResizeSquare(size uint, img image.Image) image.Image {
|
||||
return resize.Resize(size, 0, img, resize.Bilinear)
|
||||
}
|
||||
|
||||
func CropCircle(img image.Image, size int) image.Image {
|
||||
dst := image.NewRGBA(image.Rect(0, 0, size, size))
|
||||
draw.DrawMask(
|
||||
|
|
|
@ -8,10 +8,10 @@ import (
|
|||
)
|
||||
|
||||
type Details struct {
|
||||
SizePixel uint
|
||||
SizeFile int64
|
||||
Quality int
|
||||
FileName string
|
||||
SizePixel uint
|
||||
SizeFile int64
|
||||
Quality int
|
||||
FileName string
|
||||
Properties string
|
||||
}
|
||||
|
||||
|
@ -19,13 +19,6 @@ func GetSourceName(imageName string) string {
|
|||
return common.ImageDir + imageName + ".jpg"
|
||||
}
|
||||
|
||||
func makeOutputName(imageName string, size uint, i int, properties string) string {
|
||||
if properties != "" {
|
||||
properties = "_" + strings.ReplaceAll(properties, " ", "-")
|
||||
}
|
||||
return fmt.Sprintf(common.ImageDir + "%s_s-%d_q-%d%s.jpg", imageName, size, i, properties)
|
||||
}
|
||||
|
||||
func MakeDetails(imageName string, size uint, quality int, properties string) Details {
|
||||
return Details{
|
||||
SizePixel: size,
|
||||
|
@ -34,3 +27,10 @@ func MakeDetails(imageName string, size uint, quality int, properties string) De
|
|||
FileName: makeOutputName(imageName, size, quality, properties),
|
||||
}
|
||||
}
|
||||
|
||||
func makeOutputName(imageName string, size uint, i int, properties string) string {
|
||||
if properties != "" {
|
||||
properties = "_" + strings.ReplaceAll(properties, " ", "-")
|
||||
}
|
||||
return fmt.Sprintf(common.ImageDir+"%s_s-%d_q-%d%s.jpg", imageName, size, i, properties)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue