This repository has been archived by the owner on Dec 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e07f2d6
commit fa41d42
Showing
84 changed files
with
87 additions
and
72 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ | |
|
||
*.iml | ||
.idea | ||
img_output | ||
exif-remove-tool/img_output |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"errors" | ||
"fmt" | ||
"image" | ||
"image/jpeg" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/dsoprea/go-exif" | ||
"github.com/dsoprea/go-jpeg-image-structure" | ||
"github.com/dsoprea/go-png-image-structure" | ||
"github.com/scottleedavis/go-exif-remove" | ||
) | ||
|
||
func main() { | ||
|
||
if len(os.Args) == 1 { | ||
var files []string | ||
root := "img" | ||
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error { | ||
if path != "img" { | ||
files = append(files, path) | ||
} | ||
return nil | ||
}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
pass := 0 | ||
fail := 0 | ||
for _, file := range files { | ||
fmt.Println(file) | ||
if b, err := handleFile(file); err != nil { | ||
fail += 1 | ||
} else { | ||
pass += 1 | ||
f := filepath.Base(file) | ||
ioutil.WriteFile("img_output/"+f, b, 0644) | ||
} | ||
fmt.Println() | ||
} | ||
|
||
percentage := 100 * pass / (pass + fail) | ||
fmt.Printf("Results (%v%%): %v pass, %v fail \n", int(percentage), pass, fail) | ||
} else { | ||
path := os.Args[1] | ||
if b, err := handleFile(path); err != nil { | ||
fmt.Printf(err.Error()) | ||
} else { | ||
file := filepath.Base(path) | ||
ioutil.WriteFile("img_output/"+file, b, 0644) | ||
} | ||
} | ||
|
||
} | ||
|
||
func handleFile(filepath string) ([]byte, error) { | ||
if data, err := ioutil.ReadFile(filepath); err != nil { | ||
fmt.Printf(err.Error()) | ||
return nil, err | ||
} else { | ||
_, err = jpeg.Decode(bytes.NewReader(data)) | ||
if err != nil { | ||
fmt.Printf("ERROR: original image is corrupt" + err.Error() + "\n") | ||
return nil, err | ||
} | ||
filtered, err := extractEXIF(data) | ||
if err != nil { | ||
if !strings.EqualFold(err.Error(), "no exif data") { | ||
fmt.Printf("* " + err.Error() + "\n") | ||
return nil, errors.New(err.Error()) | ||
} | ||
} | ||
return filtered, nil | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// exifremove clears exif information in jpg and png files | ||
|
||
package exifremove |