feat(exiftool): handle boolean metadata

This commit is contained in:
Julien Neuhart
2024-03-23 16:40:05 +01:00
parent f4ce196a34
commit c63235cd3d
2 changed files with 5 additions and 3 deletions

View File

@@ -107,6 +107,10 @@ func (engine *ExifTool) WriteMetadata(ctx context.Context, logger *zap.Logger, m
switch val := value.(type) { switch val := value.(type) {
case string: case string:
fileMetadata[0].SetString(key, val) fileMetadata[0].SetString(key, val)
case []string:
fileMetadata[0].SetStrings(key, val)
case bool:
fileMetadata[0].SetString(key, fmt.Sprintf("%t", val))
case int: case int:
fileMetadata[0].SetInt(key, int64(val)) fileMetadata[0].SetInt(key, int64(val))
case int64: case int64:
@@ -115,8 +119,6 @@ func (engine *ExifTool) WriteMetadata(ctx context.Context, logger *zap.Logger, m
fileMetadata[0].SetFloat(key, float64(val)) fileMetadata[0].SetFloat(key, float64(val))
case float64: case float64:
fileMetadata[0].SetFloat(key, val) fileMetadata[0].SetFloat(key, val)
case []string:
fileMetadata[0].SetStrings(key, val)
// TODO: support more complex cases, e.g., arrays and nested objects // TODO: support more complex cases, e.g., arrays and nested objects
// (limitations in underlying library). // (limitations in underlying library).
default: default:

View File

@@ -184,7 +184,7 @@ func TestExiftool_WriteMetadata(t *testing.T) {
"first", "first",
"second", "second",
}, },
"Marked": "true", "Marked": true,
"ModDate": "2006-09-18T16:27:50-04:00", "ModDate": "2006-09-18T16:27:50-04:00",
"PDFVersion": 1.7, "PDFVersion": 1.7,
"Producer": "Gotenberg", "Producer": "Gotenberg",