diff --git a/common/main.go b/common/main.go new file mode 100644 index 0000000..dbd2785 --- /dev/null +++ b/common/main.go @@ -0,0 +1,3 @@ +package common + +var ImageDir = "images/" \ No newline at end of file diff --git a/files.go b/files.go index a1d10f7..ad0165d 100644 --- a/files.go +++ b/files.go @@ -7,6 +7,8 @@ import ( "log" "os" "strconv" + + "github.com/status-im/image_resizer/common" ) func getImage(fileName string) image.Image { @@ -44,10 +46,8 @@ func makeReadMe(imgDs map[string][]imageDetails) { var txt string for _, imageName := range images { - fn := imageDir + imageName + ".jpg" - 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 += "| :---: | ---------- | ----------: | ----------------: | -----------: |\n" diff --git a/image_meta.go b/image_meta.go index 6cb8d81..8ef4372 100644 --- a/image_meta.go +++ b/image_meta.go @@ -3,6 +3,8 @@ package main import ( "fmt" "strings" + + "github.com/status-im/image_resizer/common" ) type imageDetails struct { @@ -14,14 +16,14 @@ type imageDetails struct { } 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 { if 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 { diff --git a/main.go b/main.go index db4ab9d..550dd02 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,6 @@ import ( ) var ( - imageDir = "images/" images = []string{ "elephant", "frog",