Skip to content

Instantly share code, notes, and snippets.

@ttback
Last active December 26, 2015 21:59
Show Gist options
  • Save ttback/7220015 to your computer and use it in GitHub Desktop.
Save ttback/7220015 to your computer and use it in GitHub Desktop.
Blur TIFF
from PIL import Image
from PIL import ImageFilter
pageImage = Image.open('sample.tiff')
pageImage = pageImage.convert('L')
pageImage.info['compression']='raw'
pageImage=pageImage.filter(ImageFilter.GaussianBlur(4))
pageImage.save('/out/sample.tiff')
@wiredfool
Copy link

so, adding this as a test to Tests/test_file_libtiff.py:

def test_blur():
    from PIL import ImageFilter
    im = Image.open('Tests/images/pport_g4.tif')
    im = im.convert('L')
    im.info['compression']='tiff_adobe_deflate'
    im=im.filter(ImageFilter.GaussianBlur(4))
    im.save('temp.tif')

    im2 = Image.open('temp.tif')
    im2.load()

The load works, imagemagick likes it, preview doesn't.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment