Skip to content

ValueError: month must be in 1..12 #9801

Description

@malaterre

What did you do?

I would like to have a reproducible date in the sRGB default profile generated by PIL.ImageCms module.

What did you expect to happen?

Date should be set to 1900-01-01

What actually happened?

Exception is thrown upon read-back.

What are your OS, Python and Pillow versions?

  • OS: Linux
  • Python: 3.13
  • Pillow: 11.1.0
$ python3 -m PIL.report
--------------------------------------------------------------------
Pillow 11.1.0
Python 3.13.5 (main, Jul 15 2026, 20:25:40) [GCC 14.2.0]
--------------------------------------------------------------------
Python executable is /usr/bin/python3
System Python files loaded from /usr
--------------------------------------------------------------------
Python Pillow modules loaded from /usr/lib/python3/dist-packages/PIL
Binary Pillow modules loaded from /usr/lib/python3/dist-packages/PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 11.1.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.13.3
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.5.0
--- JPEG support ok, compiled for libjpeg-turbo 2.1.5
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.3
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1
--- LIBTIFF support ok, loaded 4.7.0
--- RAQM (Bidirectional Text) support ok, loaded 0.10.2
--- LIBIMAGEQUANT (Quantization method) support ok, loaded 2.18.0
--- XCB (X protocol) support ok
--------------------------------------------------------------------```
from PIL import ImageCms
import io
import struct

profile = bytearray(
    ImageCms.ImageCmsProfile(ImageCms.createProfile("sRGB")).tobytes()
)
target_date_bytes = struct.pack(">6H", 1901, 1, 1, 0, 0, 0)
profile[24:36] = target_date_bytes
icc_bytes = bytes(profile)

with open('test.icc', 'wb') as fw:
    fw.write(icc_bytes)

prof = ImageCms.ImageCmsProfile(io.BytesIO(icc_bytes))
cms = prof.profile
print(cms.creation_date)

Discussion on SO:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions