Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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
                Please include the full traceback. A wild guess is that something with a 16-bit "length" field has got too large.
– Ture Pålsson
                Mar 3, 2022 at 9:57
                Welcome to Stack Overflow. "but sometimes I get error: 'H' format requires 0 <= number <= 65535 error at the line #1 when I'm trying to save it." Okay, so what is your question about this? Did you try to figure out what the number is that it's complaining about? Did you try to figure out what the value of the number is? Did you expect to be able to use a value outside that range? If so, why? If not, then the problem is that the value is outside of that range, and should not be outside of that range. Right? So - why is it outside of that range?
– Karl Knechtel
                Mar 3, 2022 at 10:00
                Please read ericlippert.com/2014/03/05/how-to-debug-small-programs and work backwards to understand where the bad data comes from. If you cannot solve the problem yourself, even with your best effort, then show a minimal, reproducible example that lets us see the problem, along with the exact, complete, corresponding error message - copied and pasted, starting from Traceback (most recent call last):.
– Karl Knechtel
                Mar 3, 2022 at 10:02
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.