Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    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
    Dominic Bou-Samra
    @dbousamra
    I'm trying to get Pillow to use libjpeg-turbo on ubuntu 18.04. What packages do I need? And how do I tell pillow to use it? features.get_supported_features() is showing it's not enabled
    Dominic Bou-Samra
    @dbousamra
    nvm, found this: python-pillow/Pillow#3986
    Andrew Murray
    @radarhere
    Wei Jiang
    @jiangwei221
    Hi, I have a depth image whch is float32, and how can I resize it using PIL? What is the correct way to convert a 2D float32 array to a PIL Image object? Thank you!
    Andrew Murray
    @radarhere

    If you have an image file, I would try -

    from PIL import Image
    im = Image.open('image.tif')
    new_im = im.resize((100, 100))

    If by '2d float32 array' you are referring to a numpy array -

    from PIL import Image
    im = Image.fromarray(x)

    Wei Jiang
    @jiangwei221
    Ah, I see, thanks! I was confused because when I use matplotlib to display the PIL.Image object, it gives me a 4 channel uint8 image. But if I do plt.imshow(np.array(a)), it works perfectly.
    Code:
    depth_map is a 2d float32 np array
    a = Image.fromarray(depth_map, mode='F')
    plt.imshow(a) # gives me a 4 channel uint8 image
    plt.imshow(np.array(a)) # gives the correct visualization
    tkzv
    @tkzv
    Hello. What is the right way to paste images, that start at negative coordinates and use alpha channel? PIL.Image.alpha_composite doesn't accept negative coordinates, and I couldn't figure out how to use PIL.Image.paste with a mask -- it adds the new image under the original one.
    Andrew Murray
    @radarhere
    Here is how I would use paste to do that -
    from PIL import Image
    im_base = Image.open("Tests/images/hopper.jpg")
    im_overlay = Image.open("Tests/images/transparent.png")
    im_base.paste(im_overlay, (-50, -50), im_overlay)
    im_base.save('out.png')
    tkzv
    @tkzv
    I tried that and it didn't look right. But the problem was in the images. Thanks.
    Technerder
    @Technerder
    I'm running into an issue while trying to overlay text over a gif stored in a BytesIO object
                        edited_image_bytes = BytesIO()
                        image = Image.open(BytesIO(await request.read()))
                        frames = []
                        for frame in ImageSequence.Iterator(image):
                            d = ImageDraw.Draw(frame)
                            d.text((10, 100), "Hello World")
                            del d
                            b = BytesIO()
                            frame.save(b, format="GIF")
                            frames.append(Image.open(b))
                        frames[0].save(edited_image_bytes, format='GIF', save_all=True, append_images=frames[1:])
    The file is empty
    Andrew Tolmie
    @DancingQuanta
    Hi, have anyone seeing DLL not found error when piliow is install via conda-forge as dependency of matplotlib or bokeh?
    Andrew Murray
    @radarhere
    I think you’ll be interested in conda-forge/pillow-feedstock#45 and python-pillow/Pillow#4155
    Andrew Tolmie
    @DancingQuanta
    Thanks, I have commented on the recently opened issue conda-forge/pillow-feedstock#66
    Michael Adam Cabatingan
    @Peaceful-Whale
    I am trying to use Pillow with eclipse, but I keep getting this error:
    from PIL import Image
    ImportError: No module named 'PIL'
    I have PIL specified in the external library thing
    Project > Properties > PYDEV - PYTHONPATH
    I have it pointed to the folder I extracted from the download on the Pillow website
    Do I need to point to Pillow - 7.0.0 or PIL in the scr folder of Pillow - 7.0.0
    Michael Adam Cabatingan
    @Peaceful-Whale
    I get the same error if I just delete that reference
    attempting to copy just the PIL folder and use that changes nothing
    I think if I do that and restart I get a different error though
    In the "project references" it shows that it is indeed referencing PIL
    Michael Adam Cabatingan
    @Peaceful-Whale
    I tried to copy all of the files in PIL into my project, but it gives me this error when I try to import them:
    Parent module '' not loaded, cannot perform relative import
    When I stick these in a folder and then call from there
    using from folder import Image
    i get this: ImportError: cannot import name '_imaging'
    Michael Adam Cabatingan
    @Peaceful-Whale
    Image.py is failing on these import lines
    from . import ImageMode, TiffTags, UnidentifiedImageError, __version__, _plugins
    from ._binary import i8, i32le
    from ._util import deferred_error, isPath
    Parent module '' not loaded, cannot perform relative import
    Which i think is just from running Image.py when its inside the package / whatever
    but I thought that might help
    Michael Adam Cabatingan
    @Peaceful-Whale
    I have made a test .py in the folder with everything else and imported it and ran a test func
    so thats working
    it appears to be an error with something in Image.py
    and idk what to do about it. I'm assuming it's becuase its just the PIL folder and not anything else
    i have now imported the entire pillow folder
    have made a test py function, and have imported it
    so I know that works and that I can import files from the PIL folder
    when I try to import Image though i get this
    ImportError: cannot import name '_imaging'
    Michael Adam Cabatingan
    @Peaceful-Whale
    I'm guessing it's something with Image then, and I don't know how to fix it
    Nitin Pasumarthy
    @Nithanaroy

    Is there a way to identify the exact settings for Image.save from original image (to avoid image size on disk inflation)?

    img_path = Path("my_image.jpeg")
    o = Image.open(img_path)
    print(f"Original image size: {img_path.lstat().st_size}")
    ... # perform lossless transformations like crop
    o.save("transformed_img.jpeg", quality=100, subsampling=0)

    This approach leads to an increase in size. I'm not sure how to achieve this.

    Complete code which for now does not do any transformations but opens and saves the image back to disk - https://colab.research.google.com/drive/1pCtAcbZD6YsIzA7vKn7xktF7Hp-leqo7