Created
June 23, 2020 23:33
-
-
Save kerolloz/201994b9e13fd2eaa2b81f6fb55bf17d to your computer and use it in GitHub Desktop.
rotate images in current directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io/ioutil" | |
"log" | |
"regexp" | |
"github.com/disintegration/imaging" | |
) | |
func main() { | |
files, err := ioutil.ReadDir(".") | |
if err != nil { | |
log.Fatal(err) | |
} | |
imgExt := regexp.MustCompile(`^.*\.jpeg$`) // .jpeg images | |
for _, file := range files { | |
if imgExt.Match([]byte(file.Name())) { | |
fmt.Println(file.Name()) | |
src, err := imaging.Open(file.Name()) | |
if err != nil { | |
log.Fatal(err) | |
} | |
imaging.Save(imaging.Rotate270(src), "rt"+file.Name()) | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment