'Iptcinfo3 error: 'H' format requires 0 <= number <= 65535

I'm trying to change metadata of files with iptcinfo3 but sometimes I get error: 'H' format requires 0 <= number <= 65535 error at the line #1 when I'm trying to save it.

def changefiletags(filename,tags):
    info = iptcinfo3.IPTCInfo(filename)
    info['keywords'] = tags
    info.save() #1
    os.remove(filename+ '~')

How to avoid this? by the way error full text:

  File "F:\projects\pic downloader\sourcecode\imagedownloader2.py", line 44, in changefiletags
    info.save()

  File "C:\ProgramData\Anaconda3\lib\site-packages\iptcinfo3.py", line 627, in save
    return self.save_as(self._filename, options)

  File "C:\ProgramData\Anaconda3\lib\site-packages\iptcinfo3.py", line 670, in save_as
    data = self.photoshopIIMBlock(adobe, self.packedIIMData())

  File "C:\ProgramData\Anaconda3\lib\site-packages\iptcinfo3.py", line 940, in photoshopIIMBlock
    out.append(pack("!H", len(resourceBlock) + 2))  # length

error: 'H' format requires 0 <= number <= 65535


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source