Tidy up of unneeded code
This commit is contained in:
parent
bb1e232ffe
commit
aec4e43470
|
@ -1,4 +0,0 @@
|
|||
package images
|
||||
|
||||
// TODO find the best location to put the new files
|
||||
const ImageDir = "assets/"
|
|
@ -105,7 +105,7 @@ func isWebp(buf []byte) bool {
|
|||
buf[10] == 0x42 && buf[11] == 0x50
|
||||
}
|
||||
|
||||
func MakeAndRenderFile(img image.Image, imgDetail *Details) error {
|
||||
func RenderAndMakeFile(img image.Image, imgDetail *Details) error {
|
||||
out, err := os.Create(imgDetail.FileName)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -160,7 +160,7 @@ func TestMakeAndRenderFile(t *testing.T) {
|
|||
Quality: 70,
|
||||
}
|
||||
|
||||
err = MakeAndRenderFile(img, options)
|
||||
err = RenderAndMakeFile(img, options)
|
||||
require.NoError(t, err)
|
||||
require.Exactly(t, c.OutputSize, options.SizeFile)
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
package images
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
UNKNOWN FileType = 1 + iota
|
||||
|
||||
|
@ -25,18 +20,3 @@ type Details struct {
|
|||
|
||||
type FileType uint
|
||||
|
||||
func NewDetails(imageName string, size uint, quality int, properties string) Details {
|
||||
return Details{
|
||||
SizePixel: size,
|
||||
Quality: quality,
|
||||
Properties: properties,
|
||||
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(ImageDir+"%s_s-%d_q-%d%s.jpg", imageName, size, i, properties)
|
||||
}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
package images
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFileTypes(t *testing.T) {
|
||||
fmt.Printf("%d\n", WEBP)
|
||||
fmt.Printf("%d\n", SVG)
|
||||
fmt.Printf("%d\n", AI)
|
||||
}
|
Loading…
Reference in New Issue