Skip to content

Commit 8cc2511

Browse files
author
James Campbell
committed
fix: Address issues #44, #45, #50 for v2.3.0 release
- Add LICENSE file with dual Artistic-1.0 / GPL-1.0+ license (fixes #44) - Remove outdated VERSION = 1.9 comment (fixes #45) - Add UniqueList class to prevent duplicate keywords/contacts/categories (fixes #50) - Deduplicate list fields both on append and at save time - Bump version to 2.3.0
1 parent aabc05f commit 8cc2511

File tree

4 files changed

+51
-8
lines changed

4 files changed

+51
-8
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## 2.3.0 (2025-12-02)
2+
3+
### Bug Fixes
4+
- **Issue #50**: Fixed keywords and other list fields to prevent duplicate values (deduplicates on append and save)
5+
- **Issue #45**: Removed outdated VERSION = 1.9 comment from code
6+
7+
### New Features
8+
- **Issue #44**: Added LICENSE file with dual Artistic-1.0 / GPL-1.0+ license
9+
- Added `UniqueList` class for list fields that automatically prevents duplicates
10+
11+
---
12+
113
## 2.2.0 (2025-10-02)
214

315
### Bug Fixes

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
IPTCInfo3 - IPTC metadata extraction and modification for Python
2+
3+
Copyright (C) 2000-2004 Josh Carter <josh@multipart-mixed.com>
4+
Copyright (C) 2004-2008 Tamas Gulacsi <gthomas@gthomas.hu>
5+
Copyright (C) 2008-2025 James Campbell
6+
7+
DUAL LICENSE
8+
9+
This software is dual-licensed. You may choose either:
10+
11+
1. The Artistic License 1.0
12+
https://opensource.org/licenses/Artistic-1.0
13+
14+
2. The GNU General Public License v1.0 or later
15+
https://www.gnu.org/licenses/old-licenses/gpl-1.0.en.html
16+
17+
You may use, modify, and distribute this software under the terms of
18+
either license, at your option.
19+
20+
Full license texts available at the URLs above.

iptcinfo3.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# it under the terms of the Artistic License or the GNU General Public
1515
# License (GPL). You may choose either license.
1616
#
17-
# VERSION = '1.9';
1817
"""
1918
IPTCInfo - Python module for extracting and modifying IPTC image meta-data
2019
"""
@@ -27,7 +26,7 @@
2726
from struct import pack, unpack
2827
import json
2928

30-
__version__ = '2.2.0'
29+
__version__ = '2.3.0'
3130
__author__ = 'Gulácsi, Tamás'
3231
__updated_by__ = 'Campbell, James'
3332

@@ -524,6 +523,17 @@ def collect_adobe_parts(data):
524523
c_charset_r = {v: k for k, v in c_charset.items()}
525524

526525

526+
class UniqueList(list):
527+
"""A list that prevents duplicate values on append/extend."""
528+
def append(self, value):
529+
if value not in self:
530+
super().append(value)
531+
532+
def extend(self, values):
533+
for v in values:
534+
self.append(v)
535+
536+
527537
class IPTCData(dict):
528538
"""Dict with int/string keys from c_listdatanames"""
529539
def __init__(self, diction={}, *args, **kwds):
@@ -608,9 +618,9 @@ class IPTCInfo:
608618

609619
def __init__(self, fobj, force=False, inp_charset=None, out_charset=None):
610620
self._data = IPTCData({
611-
'supplemental category': [],
612-
'keywords': [],
613-
'contact': [],
621+
'supplemental category': UniqueList(),
622+
'keywords': UniqueList(),
623+
'contact': UniqueList(),
614624
})
615625
self._fobj = fobj
616626
self._force = force
@@ -956,10 +966,11 @@ def packedIIMData(self):
956966
out.append(pack("!BBBH", tag, record, dataset, len(value)))
957967
out.append(value)
958968
else:
969+
seen = set()
959970
for v in map(bytes, value):
960-
if v is None or len(v) == 0:
971+
if v is None or len(v) == 0 or v in seen:
961972
continue
962-
973+
seen.add(v)
963974
out.append(pack("!BBBH", tag, record, dataset, len(v)))
964975
out.append(v)
965976

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "IPTCInfo3"
7-
version = "2.2.0"
7+
version = "2.3.0"
88
description = "Extract and modify IPTC metadata from JPEG images"
99
readme = "README.rst"
1010
license = { text = "Artistic-1.0 OR GPL-1.0-or-later" }

0 commit comments

Comments
 (0)