Save EXIF into file metadata

This commit is contained in:
LittleSheep 2024-10-16 21:18:23 +08:00
parent 6d57ce84e6
commit 831717fabc
2 changed files with 9 additions and 8 deletions

View File

@ -4,13 +4,8 @@
<option name="autoReloadType" value="ALL" />
</component>
<component name="ChangeListManager">
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":sparkles: Attachment API can edit metadata">
<change afterPath="$PROJECT_DIR$/pkg/test_exif.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/dataSources.local.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources.local.xml" afterDir="false" />
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":lock: Fix Attachment will contains GPS information">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Dockerfile" beforeDir="false" afterPath="$PROJECT_DIR$/Dockerfile" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.mod" beforeDir="false" afterPath="$PROJECT_DIR$/go.mod" afterDir="false" />
<change beforePath="$PROJECT_DIR$/go.sum" beforeDir="false" afterPath="$PROJECT_DIR$/go.sum" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -122,7 +117,6 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value=":sparkles: List attachment original filter" />
<MESSAGE value=":sparkles: Attachment pool basis" />
<MESSAGE value=":sparkles: Attachment has pool" />
<MESSAGE value=":sparkles: Pool clean by lifecycle config" />
@ -147,7 +141,8 @@
<MESSAGE value=":bug: Fix concurrent upload multipart cause incomplete" />
<MESSAGE value=":bug: Fix account_id where clause causing indexing issue" />
<MESSAGE value=":sparkles: Attachment API can edit metadata" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Attachment API can edit metadata" />
<MESSAGE value=":lock: Fix Attachment will contains GPS information" />
<option name="LAST_COMMIT_MESSAGE" value=":lock: Fix Attachment will contains GPS information" />
</component>
<component name="VgoProject">
<settings-migrated>true</settings-migrated>

View File

@ -147,6 +147,7 @@ func AnalyzeAttachment(file models.Attachment) error {
"width": width,
"height": height,
"ratio": ratio,
"exif": map[string]any{},
}
// Removing location EXIF data
@ -160,6 +161,8 @@ func AnalyzeAttachment(file models.Attachment) error {
for k, _ := range data.Fields {
if strings.HasPrefix(k, "GPS") {
data.Clear(k)
} else {
file.Metadata["exif"].(map[string]any)[k] = data.Fields[k]
}
}
}
@ -186,6 +189,7 @@ func AnalyzeAttachment(file models.Attachment) error {
"codec_name": stream.CodecName,
"color_range": stream.ColorRange,
"color_space": stream.ColorSpace,
"exif": map[string]any{},
}
// Removing location EXIF data
@ -199,6 +203,8 @@ func AnalyzeAttachment(file models.Attachment) error {
for k, _ := range data.Fields {
if strings.HasPrefix(k, "GPS") {
data.Clear(k)
} else {
file.Metadata["exif"].(map[string]any)[k] = data.Fields[k]
}
}
}