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