mirror of
https://github.com/celogeek/go-comic-converter.git
synced 2025-06-26 15:19:56 +02:00
support jpeg or jpg extension
This commit is contained in:
parent
84e4d32f72
commit
cf0cb2ea89
@ -212,22 +212,25 @@ func LoadImages(path string, options *ImageOptions) ([]*Image, error) {
|
|||||||
return images, nil
|
return images, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadDir(input string) (int, chan *imageTask, error) {
|
func isJpeg(path string) bool {
|
||||||
|
switch strings.ToLower(filepath.Ext(path)) {
|
||||||
|
case ".jpg", ".jpeg":
|
||||||
|
{
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadDir(input string) (int, chan *imageTask, error) {
|
||||||
images := make([]string, 0)
|
images := make([]string, 0)
|
||||||
err := filepath.WalkDir(input, func(path string, d fs.DirEntry, err error) error {
|
err := filepath.WalkDir(input, func(path string, d fs.DirEntry, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if d.IsDir() {
|
if !d.IsDir() && isJpeg(path) {
|
||||||
return nil
|
images = append(images, path)
|
||||||
}
|
}
|
||||||
ext := filepath.Ext(path)
|
|
||||||
if strings.ToLower(ext) != ".jpg" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
images = append(images, path)
|
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -266,13 +269,9 @@ 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() {
|
if !f.FileInfo().IsDir() && isJpeg(f.Name) {
|
||||||
continue
|
images = append(images, f)
|
||||||
}
|
}
|
||||||
if strings.ToLower(filepath.Ext(f.Name)) != ".jpg" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
images = append(images, f)
|
|
||||||
}
|
}
|
||||||
if len(images) == 0 {
|
if len(images) == 0 {
|
||||||
r.Close()
|
r.Close()
|
||||||
@ -320,15 +319,9 @@ func loadCbr(input string) (int, chan *imageTask, error) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.IsDir {
|
if !f.IsDir && isJpeg(f.Name) {
|
||||||
continue
|
names = append(names, f.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.ToLower(filepath.Ext(f.Name)) != ".jpg" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
names = append(names, f.Name)
|
|
||||||
}
|
}
|
||||||
rl.Close()
|
rl.Close()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user