mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-05-25 08:12:36 +02:00
add png support
This commit is contained in:
parent
9738f7ba37
commit
6cf507c678
@ -6,6 +6,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
|
_ "image/jpeg"
|
||||||
|
_ "image/png"
|
||||||
"io"
|
"io"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"os"
|
"os"
|
||||||
@ -218,9 +220,9 @@ func LoadImages(path string, options *ImageOptions) ([]*Image, error) {
|
|||||||
return images, nil
|
return images, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func isJpeg(path string) bool {
|
func isSupportedImage(path string) bool {
|
||||||
switch strings.ToLower(filepath.Ext(path)) {
|
switch strings.ToLower(filepath.Ext(path)) {
|
||||||
case ".jpg", ".jpeg":
|
case ".jpg", ".jpeg", ".png":
|
||||||
{
|
{
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -234,7 +236,7 @@ func loadDir(input string) (int, chan *imageTask, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !d.IsDir() && isJpeg(path) {
|
if !d.IsDir() && isSupportedImage(path) {
|
||||||
images = append(images, path)
|
images = append(images, path)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -275,7 +277,7 @@ func loadCbz(input string) (int, chan *imageTask, error) {
|
|||||||
|
|
||||||
images := make([]*zip.File, 0)
|
images := make([]*zip.File, 0)
|
||||||
for _, f := range r.File {
|
for _, f := range r.File {
|
||||||
if !f.FileInfo().IsDir() && isJpeg(f.Name) {
|
if !f.FileInfo().IsDir() && isSupportedImage(f.Name) {
|
||||||
images = append(images, f)
|
images = append(images, f)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -325,7 +327,7 @@ func loadCbr(input string) (int, chan *imageTask, error) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if !f.IsDir && isJpeg(f.Name) {
|
if !f.IsDir && isSupportedImage(f.Name) {
|
||||||
names = append(names, f.Name)
|
names = append(names, f.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user