Skip to content

Commit

Permalink
Filter to get only photos
Browse files Browse the repository at this point in the history
creekorful committed Aug 17, 2021

Verified

This commit was signed with the committer’s verified signature.
WebFreak001 Jan Jurzitza
1 parent 46048b9 commit e1b24fe
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion gallery.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ import (
"os"
"path/filepath"
"sort"
"strings"
"time"
)

@@ -168,7 +169,7 @@ func processImages(photosDir, outputDir string) ([]map[string]interface{}, error
var photos []map[string]interface{}

if err := filepath.Walk(photosDir, func(path string, info fs.FileInfo, err error) error {
if info.IsDir() {
if !isJpegFile(info) {
return nil
}

@@ -269,3 +270,7 @@ func isPhotoProcessed(photoBytes []byte, targetPath string) bool {

return bytes.Equal(photoBytes, targetPhotoBytes)
}

func isJpegFile(file fs.FileInfo) bool {
return !file.IsDir() && (strings.HasSuffix(file.Name(), ".jpg") || strings.HasSuffix(file.Name(), ".jpeg"))
}

0 comments on commit e1b24fe

Please sign in to comment.