Moved common var to common package
This commit is contained in:
parent
c32b7ad8e3
commit
444a435402
|
@ -0,0 +1,3 @@
|
||||||
|
package common
|
||||||
|
|
||||||
|
var ImageDir = "images/"
|
6
files.go
6
files.go
|
@ -7,6 +7,8 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/status-im/image_resizer/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getImage(fileName string) image.Image {
|
func getImage(fileName string) image.Image {
|
||||||
|
@ -44,10 +46,8 @@ func makeReadMe(imgDs map[string][]imageDetails) {
|
||||||
var txt string
|
var txt string
|
||||||
|
|
||||||
for _, imageName := range images {
|
for _, imageName := range images {
|
||||||
fn := imageDir + imageName + ".jpg"
|
|
||||||
|
|
||||||
txt += "## " + imageName + "\n\n"
|
txt += "## " + imageName + "\n\n"
|
||||||
txt += fmt.Sprintf("![Original %s image](%s)\n\n", imageName, fn)
|
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 += "| Image | Properties | Size (px^2) | Image Quality (%) | Size (bytes) |\n"
|
||||||
txt += "| :---: | ---------- | ----------: | ----------------: | -----------: |\n"
|
txt += "| :---: | ---------- | ----------: | ----------------: | -----------: |\n"
|
||||||
|
|
|
@ -3,6 +3,8 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/status-im/image_resizer/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type imageDetails struct {
|
type imageDetails struct {
|
||||||
|
@ -14,14 +16,14 @@ type imageDetails struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSourceImageName(imageName string) string {
|
func getSourceImageName(imageName string) string {
|
||||||
return imageDir + imageName + ".jpg"
|
return common.ImageDir + imageName + ".jpg"
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeOutputImageName(imageName string, size uint, i int, properties string) string {
|
func makeOutputImageName(imageName string, size uint, i int, properties string) string {
|
||||||
if properties != "" {
|
if properties != "" {
|
||||||
properties = "_" + strings.ReplaceAll(properties, " ", "-")
|
properties = "_" + strings.ReplaceAll(properties, " ", "-")
|
||||||
}
|
}
|
||||||
return fmt.Sprintf(imageDir + "%s_s-%d_q-%d%s.jpg", imageName, size, i, properties)
|
return fmt.Sprintf(common.ImageDir + "%s_s-%d_q-%d%s.jpg", imageName, size, i, properties)
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeImageDetails(imageName string, size uint, quality int, properties string) imageDetails {
|
func makeImageDetails(imageName string, size uint, quality int, properties string) imageDetails {
|
||||||
|
|
Loading…
Reference in New Issue