Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    James Albert
    @jamesalbert
    Has anybody had the problem, when taking multiple cropped frames from a transparent png in order to save them as a gif, that the previous frames get tacked onto future ones?
    sprite.gif
    currently getting this ^, I can post code if needed, but I .show() each frame and none of them show this blend of frames.
    But my save looks like: snaps[0].save('build/sprite.gif', transparency=0, save_all=True, append_images=snaps[1:], loop=0)
    Andrew Murray
    @radarhere
    There are similar issues when starting with GIF images, but I’m surprised that you’re experiencing this starting with a PNG. The original image would be most helpful if you’d like this looked at a bit more.
    James Albert
    @jamesalbert
    Yeah np, got it right here
    walking-sprite.png
    as for the code, I'm just iterating over a list of quadrants, cropping them, then saving them. I'll get a snippet going here in a sec...
    James Albert
    @jamesalbert
    snaps = list()
    for q in quadrants:
        crop = image.crop(q)
        alpha = crop.getchannel('A')
        mask = Image.eval(alpha, lambda a: 255 if a <= 128 else 0)
        crop.paste(0, mask)
        crop.info['transparency'] = 255
        snaps.append(crop)
    snaps[0].save('build/sprite.gif', transparency=0, save_all=True, append_images=snaps[1:], loop=0)
    there we go (more or less), I've been experimenting with a couple different ways, none of which have worked
    James Albert
    @jamesalbert

    I also played around with:

    bg = Image.new('RGBA', crop.size, (255, 255, 255, 255))
    bg.paste(crop, alpha)
    crop = bg.convert('RGB').convert('P', palette=Image.ADAPTIVE)

    but same issue

    Andrew Murray
    @radarhere
    Okay, I was able to get your code working using ‘disposal’
    from PIL import Image
    image = Image.open('walking-sprite.png')
    snaps = []
    for i in range(0, 8):
        crop = image.crop((i * 28, 111-28, (i+1)*28, 111))
        alpha = crop.getchannel('A')
        mask = Image.eval(alpha, lambda a: 255 if a <= 128 else 0)
        crop.paste(0, mask)
        crop.info['transparency'] = 255
        snaps.append(crop)
    snaps[0].save('sprite.gif', transparency=0, save_all=True, append_images=snaps[1:], loop=0, disposal=2)
    James Albert
    @jamesalbert
    Nice @radarhere thanks a lot! After looking up what disposal is, I can see why that'd be the case :+1:
    Daniel Albuschat
    @daniel-kun
    Hello there! I'd like to add a function to Image (or some other place?) to automatically rotate an image according to it's EXIF Orientation tag, and remove that tag thereafter. Do you have interest in this?
    Andrew Murray
    @radarhere
    Sounds like a good idea to me. Feel free to create a PR
    Jeremy Moore
    @photosbyjeremy
    I need the ability to save bitonal files with a Photometric Interpretation (TIffTag 262) of 0, which is white-is-min. This is a requirement for the HathiTrust book preservation project. This is my first time trying to assist/work on someone else's project so I'm not sure exactly how to do that part of things
    In the TiffImagePlugin.py, I added this option and don't know if it would be of use to others
    alt
    alt
    Andrew Murray
    @radarhere
    Hi. The images that you’ve attached aren’t working, so I can’t comment on that. You could also create an issue at https://github.com/python-pillow/Pillow/issues and upload the images there if you want to talk about it further. Or you could try and create a pull request with your suggested code changes at https://github.com/python-pillow/Pillow/pulls
    From your description, it sounds like you’re trying to save custom tiff tags. What version of Pillow are you using? You may find that updating to the latest Pillow gives you the feature you’re after - https://pillow.readthedocs.io/en/stable/releasenotes/5.4.0.html#new-custom-tiff-tags
    Jeremy Moore
    @photosbyjeremy
    sorry, I didn't realize I was linking the images incorrectly, this link
    should hopefully work
    Jeremy Moore
    @photosbyjeremy
    I'm on the newest version of Pillow. The problem is that Photometric Interpretation seems to be hard-coded when you're saving the image, but I'm trying out using the a custom tag
    I'd just tried using tiffinfo = {262: 0} before, but I think that wasn't the correct value to pass as it doesn't work with the code I linked either. I think it needs to be (0, ) and NOT 0 tiffinfo = {262:(0,)} like my linked code needs (just replacing ifd directly while saving)
    Jeremy Moore
    @photosbyjeremy
    Is the problem that Photometric Interpretation isn't a custom tag?
    I'll upload this as an issue to GitHub
    Martin Malmsten
    @marma
    Hi. I'm using PIL to serve images using the IIIF protocol and have a performance question. Has there been any work done, or interest shown, in partial decoding of JPEG2000-images? There are two things that speed up the decompression of an image a lot when using opj_decompress: (1) reducing the size by a power of two and (2) cropping. This is useful when creating tiles and/or thumbnails on the fly from large image collections, i.e when you don't want to create and save a huge number of pre-scaled/cropped tiles and sizes. As far as I can tell you can set Jpeg2KImageFile.reduce to decrease the final size which will result in faster decode time, but there is no way to decode only the cropped region. Am I correct, or his there any way to tell PIL to tell OpenJPEG to do partial decoding?
    Ivan
    @advancedwebdeveloper
    Hello
    I wonder if there are any attempts to adopt your lib for accessing from the side of Autodesk's Python SDK/for an integration purpose
    looks like your lib is itself is a replacement for the relict one, which it is still referencing
    plus I wonder about the language version - products' versions for 2014 relly on Python 2.x, not 3.x
    ...who is coming to the PyCon Ukraine 2019?
    Andrew Murray
    @radarhere
    Pillow currently works with both Python 2 and 3. However, at the start of 2020, Pillow 7.0.0 will drop support for Python 2. See https://pythonclock.org/ and https://python3statement.org/
    Ivan
    @advancedwebdeveloper

    Pillow currently works with both Python 2 and 3. However, at the start of 2020, Pillow 7.0.0 will drop support for Python 2. See https://pythonclock.org/ and https://python3statement.org/

    It does not seam that Autodesk switched their Python SDK to Python 3.x. At least - not for their current releases of their products

    Andrew
    @apullin
    Is there a build artifact for windows for 6.1.0.x ? I am up against bug #3772, in a Windows environment. On a separate machine under OSX, I was easily able to build from source, but I would like it to work on this desktop PC (compute machine w/ GPU).
    Andrew
    @apullin
    Or if someone already has a Windows/Python 3.7 build environment set up and known working (I can't get it to work here), and could build 6.1.0.dev0 for my and give me the egg, that would be super useful.
    Andrew Murray
    @radarhere
    Pillow uses AppVeyor for testing, and eggs artifacts are created as part of that process. So, here are the artifacts for Windows Python 3.7 from one merge after the #3772 fix
    Be aware that the environment used to create those was not set up with LCMS2, RAQM or libimagequant.
    Andrew
    @apullin
    @radarhere Thanks, that worked for me!
    Ajay Tripathi
    @atb00ker
    Hello, I am using alpine linux and I need zlib-dev and jpeg-dev before doing pip install pillow
    I am trying to figure out if these libraries are build dependencies or required for usage as well because everything seems to work right now but I am ensuring nothing will break in future. :-)
    Andrew Murray
    @radarhere
    Bruce Elbert Bigirwenkya
    @Elbertbiggs360
    Hi. Can anyone here point point me to a reference about resolving the underlying issues from ghostscript about multiple -dSAFER sandbox bypass vulnerabilities
    Andrew Murray
    @radarhere
    There are a number of SAFER fixes in Ghostscript 9.26 - https://www.ghostscript.com/doc/9.26/History9.htm#Version9.26. Does that not address your concerns?
    Bruce Elbert Bigirwenkya
    @Elbertbiggs360
    @radarhere I believe it should. Thanks :slight_smile:
    Bruce Elbert Bigirwenkya
    @Elbertbiggs360
    I am new to the library. Can you help point me to anything that details how ghostscript as a dependency is installed
    Andrew Murray
    @radarhere
    Ghostscript is actually not integrated into Pillow through any kind of C calls - Pillow just uses Ghostscript by making command line 'gs' calls (or ‘gswin32c' or ‘gswin64c' as the case may be). So regardless of whether you already have Pillow installed or not, you just need to ensure that Ghostscript is installed on your system - no special instructions necessary.

    Or are you just asking how to install Ghostscript at all? If so, what operating system are you using?

    https://www.ghostscript.com/download/gsdnld.html

    Bruce Elbert Bigirwenkya
    @Elbertbiggs360
    I have Debian GNU/Linux instance on GCP. Let me check up on the shared link :slight_smile:
    Bruce Elbert Bigirwenkya
    @Elbertbiggs360
    Ok so the instance has v9.26 of GS which should be secure enough. I'll merely upgrade the version of Pillow I'm using to the latest and pick up from there