image-resizer/images/meta.go

37 lines
812 B
Go
Raw Normal View History

package images
import (
"fmt"
"strings"
2020-09-18 14:47:44 +00:00
"github.com/status-im/image_resizer/common"
)
type Details struct {
2020-09-18 15:22:10 +00:00
SizePixel uint
SizeFile int64
Quality int
FileName string
Properties string
}
func GetSourceName(imageName string) string {
2020-09-18 14:47:44 +00:00
return common.ImageDir + imageName + ".jpg"
}
func MakeDetails(imageName string, size uint, quality int, properties string) Details {
return Details{
SizePixel: size,
Quality: quality,
Properties: properties,
FileName: makeOutputName(imageName, size, quality, properties),
}
}
2020-09-18 15:22:10 +00:00
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)
}