{"action":"created","issue":{"url":"https://api.github.com/repos/python-pillow/Pillow/issues/1280","labels_url":"https://api.github.com/repos/python-pillow/Pillow/issues/1280/labels{/name}","comments_url":"https://api.github.com/repos/python-pillow/Pillow/issues/1280/comments","events_url":"https://api.github.com/repos/python-pillow/Pillow/issues/1280/events","html_url":"https://github.com/python-pillow/Pillow/issues/1280","id":89124244,"number":1280,"title":"Docs not providing required information for setting image pallets","user":{"login":"Tcll","id":773959,"avatar_url":"https://avatars.githubusercontent.com/u/773959?v=3","gravatar_id":"","url":"https://api.github.com/users/Tcll","html_url":"https://github.com/Tcll","followers_url":"https://api.github.com/users/Tcll/followers","following_url":"https://api.github.com/users/Tcll/following{/other_user}","gists_url":"https://api.github.com/users/Tcll/gists{/gist_id}","starred_url":"https://api.github.com/users/Tcll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tcll/subscriptions","organizations_url":"https://api.github.com/users/Tcll/orgs","repos_url":"https://api.github.com/users/Tcll/repos","events_url":"https://api.github.com/users/Tcll/events{/privacy}","received_events_url":"https://api.github.com/users/Tcll/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/python-pillow/Pillow/labels/Documentation","name":"Documentation","color":"f7c6c7"},{"url":"https://api.github.com/repos/python-pillow/Pillow/labels/Enhancement","name":"Enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/python-pillow/Pillow/labels/Needs%20Documentation","name":"Needs Documentation","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-06-17T20:56:43Z","updated_at":"2015-12-09T03:41:22Z","closed_at":null,"body":"OT: don't bite me because I use pallet and not palette. (this is the only thing I use that uses palette)\r\n\r\nso I'm trying to create a new image and write a pallet to it, but the data I'm providing is in formats of:\r\n- [ I/L ]\r\n- [ I/L, A ]\r\n- [ R, G, B ]\r\n- [ R, G, B, A ]\r\n\r\nif I specify `pmode = ['L','LA','RGB','RGBA'][len(pallet[0])]`, is that compatible with `img.putpalette(pallet, pmode)`??\r\n\r\nalso, the pallet data I'm providing is not of a fixed size, and will give as many colors as it was originally provided.\r\n\r\nfor more of an idea, here's the export portion of my program's image I/O script:\r\n\r\n    def ugeExportImage(FT,CMD):\r\n        #name = ugeGetImageName()\r\n        width = ugeGetImageWidth()\r\n        height = ugeGetImageHeight()\r\n        pixels = ugeGetImageData()\r\n        pallet = ugeGetImagePallet()\r\n\r\n        mode = ['L','LA','RGB','RGBA'][len(pixels[0])-1]\r\n        pmode= None\r\n        if pallet!=[] and mode=='L': mode='P'; pmode = ['L','LA','RGB','RGBA'][len(pallet[0])-1]\r\n        \r\n        img = Image.new( mode, (width,height))\r\n        img.putdata([tuple(p) for p in pixels])\r\n        if mode=='P': img.putpalette( pallet, pmode )\r\n        \r\n        Data = StringIO()\r\n        img.save(Data, format=FT)\r\n        Data.seek(0)\r\n        string(Data.read())\r\n\r\nthe documentation doesn't tell me what pallet formats are supported, nor does it tell me all pallet sequence types."},"comment":{"url":"https://api.github.com/repos/python-pillow/Pillow/issues/comments/163095524","html_url":"https://github.com/python-pillow/Pillow/issues/1280#issuecomment-163095524","issue_url":"https://api.github.com/repos/python-pillow/Pillow/issues/1280","id":163095524,"user":{"login":"radarhere","id":3112309,"avatar_url":"https://avatars.githubusercontent.com/u/3112309?v=3","gravatar_id":"","url":"https://api.github.com/users/radarhere","html_url":"https://github.com/radarhere","followers_url":"https://api.github.com/users/radarhere/followers","following_url":"https://api.github.com/users/radarhere/following{/other_user}","gists_url":"https://api.github.com/users/radarhere/gists{/gist_id}","starred_url":"https://api.github.com/users/radarhere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radarhere/subscriptions","organizations_url":"https://api.github.com/users/radarhere/orgs","repos_url":"https://api.github.com/users/radarhere/repos","events_url":"https://api.github.com/users/radarhere/events{/privacy}","received_events_url":"https://api.github.com/users/radarhere/received_events","type":"User","site_admin":false},"created_at":"2015-12-09T03:41:22Z","updated_at":"2015-12-09T03:41:22Z","body":"Looks like the `rawmode` parameter can any of the RGB section of this list - https://github.com/python-pillow/Pillow/blob/master/libImaging/Unpack.c#L1080\r\n\r\nI think if we started inserting mode lists of this length in the documentation, it could become cluttered. Perhaps someone can suggest a more organised approach to this?\r\n\r\n\r\nAs an aside -\r\n\r\nhttps://pillow.readthedocs.org/en/3.0.x/reference/Image.html#PIL.Image.Image.putpalette -\r\n\r\n    Attaches a palette to this image.  The image must be a \"P\" or\r\n    \"L\" image, and the palette sequence must contain 768 integer\r\n    values, where each group of three values represent the red,\r\n    green, and blue values for the corresponding pixel index.\r\n    Instead of an integer sequence, you can use an 8-bit string.\r\n    \r\n    Parameters:\tdata – A palette sequence (either a list or a string).\r\n\r\nYour code can create images of modes L, LA, RGB and RGBA - rather than just P or L as specified in the documentation."}}