mirror of
https://github.com/gen2brain/cbconvert
synced 2025-10-14 02:28:51 +02:00
Use bild library
This commit is contained in:
@@ -2,41 +2,12 @@ package cbconvert
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// imageToRGBA converts an image.Image to *image.RGBA.
|
||||
func imageToRGBA(src image.Image) *image.RGBA {
|
||||
if dst, ok := src.(*image.RGBA); ok {
|
||||
return dst
|
||||
}
|
||||
|
||||
b := src.Bounds()
|
||||
dst := image.NewRGBA(b)
|
||||
draw.Draw(dst, dst.Bounds(), src, b.Min, draw.Src)
|
||||
|
||||
return dst
|
||||
}
|
||||
|
||||
// imageToGray converts an image.Image to *image.Gray.
|
||||
func imageToGray(src image.Image) *image.Gray {
|
||||
if dst, ok := src.(*image.Gray); ok {
|
||||
return dst
|
||||
}
|
||||
|
||||
b := src.Bounds()
|
||||
dst := image.NewGray(b)
|
||||
draw.Draw(dst, dst.Bounds(), src, b.Min, draw.Src)
|
||||
|
||||
return dst
|
||||
}
|
||||
|
||||
// imagesFromPath returns list of found image files for given directory.
|
||||
func imagesFromPath(path string) ([]string, error) {
|
||||
var images []string
|
||||
@@ -147,16 +118,6 @@ func isSize(a, b int64) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// isGrayScale checks if image is grayscale.
|
||||
func isGrayScale(img image.Image) bool {
|
||||
model := img.ColorModel()
|
||||
if model == color.GrayModel || model == color.Gray16Model {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// baseNoExt returns base name without extension.
|
||||
func baseNoExt(filename string) string {
|
||||
return strings.TrimSuffix(filepath.Base(filename), filepath.Ext(filename))
|
||||
|
Reference in New Issue
Block a user