Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write IPTC Sublocation #112

Merged
merged 3 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ of Ashampoo Photo Organizer, which, in turn, is driven by user community feedbac
## Installation

```
implementation("com.ashampoo:kim:0.22")
implementation("com.ashampoo:kim:0.22.1")
```

For the targets `wasmJs` & `js` you also need to specify this:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public object PhotoMetadataConverter {

return LocationShown(
name = null,
location = null,
street = null,
city = iptcCity,
state = iptcState,
country = iptcCountry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,19 @@ internal object JpegUpdater : MetadataUpdater {

newRecords.addAll(
oldRecords.filter {
it.iptcType != IptcTypes.CITY &&
it.iptcType != IptcTypes.SUBLOCATION &&
it.iptcType != IptcTypes.CITY &&
it.iptcType != IptcTypes.PROVINCE_STATE &&
it.iptcType != IptcTypes.COUNTRY_PRIMARY_LOCATION_NAME
}
)

if (update.locationShown != null) {

update.locationShown.street?.let { location ->
newRecords.add(IptcRecord(IptcTypes.SUBLOCATION, location))
}

update.locationShown.city?.let { city ->
newRecords.add(IptcRecord(IptcTypes.CITY, city))
}
Expand All @@ -252,6 +257,7 @@ internal object JpegUpdater : MetadataUpdater {

newRecords.addAll(
oldRecords.filter {
it.iptcType != IptcTypes.SUBLOCATION &&
it.iptcType != IptcTypes.CITY &&
it.iptcType != IptcTypes.PROVINCE_STATE &&
it.iptcType != IptcTypes.COUNTRY_PRIMARY_LOCATION_NAME
Expand All @@ -260,6 +266,10 @@ internal object JpegUpdater : MetadataUpdater {

if (update.locationShown != null) {

update.locationShown.street?.let { location ->
newRecords.add(IptcRecord(IptcTypes.SUBLOCATION, location))
}

update.locationShown.city?.let { city ->
newRecords.add(IptcRecord(IptcTypes.CITY, city))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public object XmpReader {

LocationShown(
name = it.name,
location = it.location,
street = it.location,
city = it.city,
state = it.state,
country = it.country
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public object XmpWriter {
setLocation(
XMPLocation(
name = locationShown.name,
location = locationShown.location,
location = locationShown.street,
city = locationShown.city,
state = locationShown.state,
country = locationShown.country
Expand Down Expand Up @@ -123,7 +123,7 @@ public object XmpWriter {
setLocation(
XMPLocation(
name = locationShown.name,
location = locationShown.location,
location = locationShown.street,
city = locationShown.city,
state = locationShown.state,
country = locationShown.country
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ public data class LocationShown(

/**
* Often a street adress like "Schafjückenweg 2"
*
* Also known as "Sublocation".
*/
val location: String?,
val street: String?,

/**
* The city, for example "Rastede"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class PhotoMetadataConverterTest {
"$name;${metadata.imageFormat};${metadata.widthPx};${metadata.heightPx};" +
"${metadata.orientation};${metadata.takenDate};" +
"${metadata.gpsCoordinates?.latitude};${metadata.gpsCoordinates?.longitude};" +
"${metadata.locationShown?.name};${metadata.locationShown?.location};" +
"${metadata.locationShown?.name};${metadata.locationShown?.street};" +
"${metadata.locationShown?.city};${metadata.locationShown?.state};" +
"${metadata.locationShown?.country};" +
"${metadata.cameraMake};${metadata.cameraModel};${metadata.lensMake};" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstract class AbstractUpdaterTest(

private val crashBuildingLocation = LocationShown(
name = "//CRASH",
location = "Schafjückenweg 2",
street = "Schafjückenweg 2",
city = "Rastede",
state = "Niedersachsen",
country = "Deutschland"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class XmpReaderTest {
),
locationShown = LocationShown(
name = null,
location = "Wahnbek",
street = "Wahnbek",
city = "Rastede",
state = "Niedersachsen",
country = "Germany"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
File format : JPEG
Resolution : 2304 x 1536
---- TIFF ----
Version 42
Little-endian (Intel, II)
---- Directory IFD0 @ 8 ----
0000000010 0x010e ImageDescription =
0000000022 0x010f Make = Canon
0000000034 0x0110 Model = Canon EOS M3
0000000046 0x0112 Orientation = 1
0000000058 0x011a XResolution = 180/1 (180.0)
0000000070 0x011b YResolution = 180/1 (180.0)
0000000082 0x0128 ResolutionUnit = 2
0000000094 0x0132 ModifyDate = 2017:11:12 22:26:16
0000000106 0x0213 YCbCrPositioning = 2
0000000118 0x8769 ExifOffset = 234
0000000130 0x8825 GPSInfo = 18576

---- Directory ExifIFD @ 234 ----
0000000236 0x829a ExposureTime = 1/4000 (2.5E-4)
0000000248 0x829d FNumber = 56/10 (5.6)
0000000260 0x8822 ExposureProgram = 4
0000000272 0x8827 ISO = 3200
0000000284 0x8830 SensitivityType = 2
0000000296 0x8832 RecommendedExposureIndex = 3200
0000000308 0x9000 ExifVersion = [0x30, 0x32, 0x33, 0x30]
0000000320 0x9003 DateTimeOriginal = 2017:11:12 21:41:48
0000000332 0x9004 DateTimeDigitized = 2017:11:12 21:41:48
0000000344 0x9101 ComponentsConfiguration = [0x01, 0x02, 0x03, 0x00]
0000000356 0x9102 CompressedBitsPerPixel = 3/1 (3.0)
0000000368 0x9201 ShutterSpeedValue = 383/32 (11.96875)
0000000380 0x9202 ApertureValue = 159/32 (4.96875)
0000000392 0x9204 ExposureCompensation = 0/3 (0.0)
0000000404 0x9207 MeteringMode = 5
0000000416 0x9209 Flash = 16
0000000428 0x920a FocalLength = 55/1 (55.0)
0000000440 0x927c MakerNote = [17582 bytes]
0000000452 0x9290 SubSecTime =
0000000464 0x9291 SubSecTimeOriginal = 76
0000000476 0x9292 SubSecTimeDigitized = 76
0000000488 0xa000 FlashpixVersion = [0x30, 0x31, 0x30, 0x30]
0000000500 0xa001 ColorSpace = 1
0000000512 0xa002 ExifImageWidth = 2304
0000000524 0xa003 ExifImageHeight = 1536
0000000536 0xa005 InteropOffset = 18522
0000000548 0xa20e FocalPlaneXResolution = 2304000/879 (2621.16041)
0000000560 0xa20f FocalPlaneYResolution = 1536000/586 (2621.16041)
0000000572 0xa210 FocalPlaneResolutionUnit = 2
0000000584 0xa217 SensingMethod = 2
0000000596 0xa300 FileSource = 3
0000000608 0xa401 CustomRendered = 0
0000000620 0xa402 ExposureMode = 0
0000000632 0xa403 WhiteBalance = 1
0000000644 0xa404 DigitalZoomRatio = 6000/6000 (1.0)
0000000656 0xa406 SceneCaptureType = 0
0000000668 0xa430 CameraOwnerName =
0000000680 0xa431 BodySerialNumber = 073043001183
0000000692 0xa432 LensSpecification = [18/1 (18.0), 55/1 (55.0), 0/1 (0.0), 0/1 (0.0)]
0000000704 0xa434 LensModel = EF-M18-55mm f/3.5-5.6 IS STM
0000000716 0xa435 LensSerialNumber = 0000455071

---- Directory InteropIFD @ 18522 ----
0000018524 0x0001 InteroperabilityIndex = R98
0000018536 0x0002 InteroperabilityVersion = [0x30, 0x31, 0x30, 0x30]
0000018548 0x1001 RelatedImageWidth = 2304
0000018560 0x1002 RelatedImageHeight = 1536

---- Directory GPS @ 18576 ----
0000018578 0x0000 GPSVersionID = [0x02, 0x03, 0x00, 0x00]
0000018590 0x0001 GPSLatitudeRef = N
0000018602 0x0002 GPSLatitude = [53/1 (53.0), 13/1 (13.0), 24519/2500 (9.8076)]
0000018614 0x0003 GPSLongitudeRef = E
0000018626 0x0004 GPSLongitude = [8/1 (8.0), 14/1 (14.0), 56949/2500 (22.7796)]

---- Directory IFD1 @ 18690 ----
0000018692 0x0103 Compression = 6
0000018704 0x011a XResolution = 180/1 (180.0)
0000018716 0x011b YResolution = 180/1 (180.0)
0000018728 0x0128 ResolutionUnit = 2
0000018740 0x0201 JpgFromRawStart = 18784
0000018752 0x0202 JpgFromRawLength = 3209

---- Directory MakerNoteCanon @ 864 ----
0000000866 0x0001 CanonCameraSettings = [50 shorts]
0000000878 0x0003 Unknown = [0, 0, 0, 0]
0000000890 0x0004 Unknown = [34 shorts]
0000000902 0x0006 CanonImageType = IMG:EOS M3 JPEG
0000000914 0x0007 CanonFirmwareVersion = Firmware Version 1.01
0000000926 0x0008 FileNumber = 1237368
0000000938 0x000d Unknown = [3684 ints]
0000000950 0x0010 CanonModelID = 57933824
0000000962 0x0013 Unknown = [0, 159, 7, 112]
0000000974 0x0018 Unknown = [256 bytes]
0000000986 0x0019 Unknown = 1
0000000998 0x001c Unknown = 0
0000001010 0x001e Unknown = 16843008
0000001022 0x0022 Unknown = [208 shorts]
0000001034 0x0023 Unknown = [8, 0]
0000001046 0x0027 Unknown = [21 shorts]
0000001058 0x0028 Unknown = [0x6d, 0x0c, 0xe7, 0x33, 0xaf, 0xf8, 0xd1, 0xdc, 0x5a, 0xeb, 0x38, 0x82, 0x5e, 0x81, 0x04, 0x2f]
0000001070 0x002d Unknown = 0
0000001082 0x002e Unknown = [27 shorts]
0000001094 0x002f Unknown = [17 shorts]
0000001106 0x0031 Unknown = [12, 1, -1, -1, -1, -1]
0000001118 0x0033 Unknown = [-1493755867, -590263106, -2110198950, 788824414]
0000001130 0x0035 Unknown = [16, 0, 32766, 0]
0000001142 0x0037 Unknown = [8, 0]
0000001154 0x0038 Unknown = [0x08, 0x00, 0x00, 0x00, 0x70, 0x29, 0xd5, 0x7b]
0000001166 0x003c Unknown = [218 shorts]
0000001178 0x003d Unknown = [32, 1, 0, 0, 0, 0, 0, 0]
0000001190 0x003f Unknown = 1
0000001202 0x0093 Unknown = [33 shorts]
0000001214 0x0096 InternalSerialNumber = SA0151220
0000001226 0x0099 Unknown = [34 ints]
0000001238 0x009a Unknown = [0, 2304, 1536, 0, 0]
0000001250 0x00a0 Unknown = [28, 0, 0, -1, -1, -1, -1, -1, -1, -1, 132, 0, 9, -1]
0000001262 0x00aa Unknown = [12, 392, 545, 546, 2614, 0]
0000001274 0x00d0 Unknown = 0
0000001286 0x4008 Unknown = [135, 135, 135]
0000001298 0x4009 Unknown = [255, 255, 255]
0000001310 0x4010 Unknown =
0000001322 0x4012 Unknown =
0000001334 0x4016 Unknown = [32, 0, 1, 0, 1, 1, 1, 0]
0000001346 0x4018 Unknown = [36, 0, 0, 0, 0, 0, 1, 0, 1]
0000001358 0x4020 Unknown = [28, 0, 0, 0, 0, 0, 0]
0000001370 0x4023 Unknown = [16, 1, 4320, 2880]
0000001382 0x4024 Unknown = [53 ints]
0000001394 0x402b Unknown = [24, 0, 0, 0, 0, 0]
0000001406 0x402c Unknown = [8, 0]

---- IPTC ----
Caption/Abstract (120) = 'time lapse photography of fire'
Country/Primary Location Name (101) = 'Deutschland'
Province/State (95) = 'Niedersachsen'
Sublocation (92) = 'Schafjückenweg 2'
City (90) = 'Rastede'
Keywords (25) = 'human'
Keywords (25) = 'person'
Keywords (25) = 'people'

---- XMP ----
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Ashampoo XMP Core 1.5.0">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/"
xmlns:Iptc4xmpExt="http://iptc.org/std/Iptc4xmpExt/2008-02-29/"
xmlns:exif="http://ns.adobe.com/exif/1.0/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
xmlns:xmp="http://ns.adobe.com/xap/1.0/"
Iptc4xmpCore:Location="Schafjückenweg 2"
exif:GPSLatitude="53,13.1635N"
exif:GPSLongitude="8,14.3797E"
exif:GPSVersionID="2.3.0.0"
photoshop:City="Rastede"
photoshop:Country="Deutschland"
photoshop:State="Niedersachsen"
xmp:Rating="2">
<Iptc4xmpExt:LocationShown>
<rdf:Bag>
<rdf:li>
<rdf:Description
Iptc4xmpExt:City="Rastede"
Iptc4xmpExt:CountryName="Deutschland"
Iptc4xmpExt:ProvinceState="Niedersachsen"
Iptc4xmpExt:Sublocation="Schafjückenweg 2">
<Iptc4xmpExt:LocationName>
<rdf:Alt>
<rdf:li xml:lang="x-default">//CRASH</rdf:li>
</rdf:Alt>
</Iptc4xmpExt:LocationName>
</rdf:Description>
</rdf:li>
</rdf:Bag>
</Iptc4xmpExt:LocationShown>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
File format : JPEG
Resolution : 2304 x 1536
---- TIFF ----
Version 42
Big-endian (Motorola, MM)
---- Directory IFD0 @ 8 ----
0000000010 0x8769 ExifOffset = 40
0000000022 0x8825 GPSInfo = 48

---- Directory ExifIFD @ 40 ----

---- Directory GPS @ 48 ----
0000000050 0x0000 GPSVersionID = [0x02, 0x03, 0x00, 0x00]
0000000062 0x0001 GPSLatitudeRef = N
0000000074 0x0002 GPSLatitude = [53/1 (53.0), 13/1 (13.0), 24519/2500 (9.8076)]
0000000086 0x0003 GPSLongitudeRef = E
0000000098 0x0004 GPSLongitude = [8/1 (8.0), 14/1 (14.0), 56949/2500 (22.7796)]

---- IPTC ----
Country/Primary Location Name (101) = 'Deutschland'
Province/State (95) = 'Niedersachsen'
Sublocation (92) = 'Schafjückenweg 2'
City (90) = 'Rastede'

---- XMP ----
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Ashampoo XMP Core 1.5.0">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/"
xmlns:Iptc4xmpExt="http://iptc.org/std/Iptc4xmpExt/2008-02-29/"
xmlns:exif="http://ns.adobe.com/exif/1.0/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
Iptc4xmpCore:Location="Schafjückenweg 2"
exif:GPSLatitude="53,13.1635N"
exif:GPSLongitude="8,14.3797E"
exif:GPSVersionID="2.3.0.0"
photoshop:City="Rastede"
photoshop:Country="Deutschland"
photoshop:State="Niedersachsen">
<Iptc4xmpExt:LocationShown>
<rdf:Bag>
<rdf:li>
<rdf:Description
Iptc4xmpExt:City="Rastede"
Iptc4xmpExt:CountryName="Deutschland"
Iptc4xmpExt:ProvinceState="Niedersachsen"
Iptc4xmpExt:Sublocation="Schafjückenweg 2">
<Iptc4xmpExt:LocationName>
<rdf:Alt>
<rdf:li xml:lang="x-default">//CRASH</rdf:li>
</rdf:Alt>
</Iptc4xmpExt:LocationName>
</rdf:Description>
</rdf:li>
</rdf:Bag>
</Iptc4xmpExt:LocationShown>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Little-endian (Intel, II)
Caption/Abstract (120) = 'time lapse photography of fire'
Country/Primary Location Name (101) = 'Deutschland'
Province/State (95) = 'Niedersachsen'
Sublocation (92) = 'Schafjückenweg 2'
City (90) = 'Rastede'
Keywords (25) = 'human'
Keywords (25) = 'person'
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Resolution : 2304 x 1536
---- IPTC ----
Country/Primary Location Name (101) = 'Deutschland'
Province/State (95) = 'Niedersachsen'
Sublocation (92) = 'Schafjückenweg 2'
City (90) = 'Rastede'

---- XMP ----
Expand Down