Closed molecule closed 6 years ago
Investigating -
>>> dir(im.getdata())
['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__',
'bands', 'box_blur', 'chop_add', 'chop_add_modulo', 'chop_and', 'chop_darker',
'chop_difference', 'chop_invert', 'chop_lighter', 'chop_multiply', 'chop_or',
'chop_screen', 'chop_subtract', 'chop_subtract_modulo', 'chop_xor',
'color_lut_3d', 'convert', 'convert2', 'convert_matrix', 'convert_transparent',
'copy', 'crop', 'effect_spread', 'expand', 'fillband', 'filter', 'gaussian_blur',
'getband', 'getbbox', 'getcolors', 'getextrema', 'getpalette', 'getpalettemode',
'getpixel', 'getprojection', 'histogram', 'id', 'isblock', 'mode', 'modefilter',
'new_block', 'offset', 'paste', 'pixel_access', 'point', 'point_transform', 'ptr',
'putband', 'putdata', 'putpalette', 'putpalettealpha', 'putpalettealphas',
'putpixel', 'quantize', 'rankfilter', 'resize', 'save_ppm', 'setmode', 'size',
'split', 'transform2', 'transpose', 'unsafe_ptrs', 'unsharp_mask']
Which would correspond to these methods, as set on the object
Thanks! I see the actual method definition now: https://github.com/python-pillow/Pillow/blob/90a94e7dae19f75363c769713b1b6d10eb16f613/src/_imaging.c#L466
Is there any example of "get_pixel" being used somewhere? Or more information about what "ImagingAccess access" is supposed to represent? Or int x and int y? I can read through the code and try to figure it out, but I'm hoping there is some information in the otherwise excellent docs that I've missed!
Alternatively: I'm trying to write a compression algorithm for some custom .xbm files. To do so, I need low-level access to the actual bits of the images. Am I going about this in the wrong way? Is there another function I've missed that lets me iterate through the image bits and perform tasks on them?
Here is a C function that calls that - https://github.com/python-pillow/Pillow/blob/90a94e7dae19f75363c769713b1b6d10eb16f613/src/_imaging.c#L1139-L1162
This is in turn called from Python - https://github.com/python-pillow/Pillow/blob/90a94e7dae19f75363c769713b1b6d10eb16f613/src/PIL/Image.py#L1284-L1297
The prettier documentation for this is at https://pillow.readthedocs.io/en/5.2.x/reference/Image.html?#PIL.Image.Image.getpixel
So if all you are after is getting the value of a pixel, you don't need to go through getdata()
, you can fetch the value directly. There is also putpixel
- https://pillow.readthedocs.io/en/5.2.x/reference/Image.html?#PIL.Image.Image.putpixel.
If you are interested in going through and changing individual pixels, there is also PixelAccess
- https://pillow.readthedocs.io/en/5.2.x/reference/PixelAccess.html
@molecule do you have any further questions, or is this issue resolved?
Not resolved, but I have a major deadline in the next two weeks, so won't be able to look at this for a while. Thanks for the links.
On Thu, Aug 30, 2018 at 3:35 AM Andrew Murray notifications@github.com wrote:
@molecule https://github.com/molecule do you have any further questions, or is this issue resolved?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/python-pillow/Pillow/issues/3307#issuecomment-417273161, or mute the thread https://github.com/notifications/unsubscribe-auth/ABGsjGAHW8Niz9D4qYoJVSVFDjjQOnCXks5uV8AIgaJpZM4WDCZT .
-- UC Berkeley / CS PhD Student / New Media DE BCNM - Invention Lab - Liebe Wetzel's Lunatique Fantastique UC Berkeley CS/CogSci '14 https://molecule.github.io/ https://molecule.github.io/
Hi. Any updates? I'd just like to close this issue if it is resolved.
This can be re-opened if there is anything further.
The docs say:
src
Where can I learn more about the "certain sequence operations" that this internal PIL data type supports?
Here's what I've tried:
im.getdata().len
which returns:AttributeError: 'ImagingCore' object has no attribute 'len'
So now I know the data type is known as "ImagingCore".img.getdata()
to get the length of the sequence. No other uses are shown.Where can I learn more about the "certain sequence operations" that this internal PIL data type supports?