Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6633541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:49:31+00:00 2026-05-25T22:49:31+00:00

I need a python method to open and import TIFF images into numpy arrays

  • 0

I need a python method to open and import TIFF images into numpy arrays so I can analyze and modify the pixel data and then save them as TIFFs again. (They are basically light intensity maps in greyscale, representing the respective values per pixel)

I couldn’t find any documentation on PIL methods concerning TIFF. I tried to figure it out, but only got “bad mode” or “file type not supported” errors.

What do I need to use here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T22:49:32+00:00Added an answer on May 25, 2026 at 10:49 pm

    First, I downloaded a test TIFF image from this page called a_image.tif. Then I opened with PIL like this:

    >>> from PIL import Image
    >>> im = Image.open('a_image.tif')
    >>> im.show()
    

    This showed the rainbow image. To convert to a numpy array, it’s as simple as:

    >>> import numpy
    >>> imarray = numpy.array(im)
    

    We can see that the size of the image and the shape of the array match up:

    >>> imarray.shape
    (44, 330)
    >>> im.size
    (330, 44)
    

    And the array contains uint8 values:

    >>> imarray
    array([[  0,   1,   2, ..., 244, 245, 246],
           [  0,   1,   2, ..., 244, 245, 246],
           [  0,   1,   2, ..., 244, 245, 246],
           ..., 
           [  0,   1,   2, ..., 244, 245, 246],
           [  0,   1,   2, ..., 244, 245, 246],
           [  0,   1,   2, ..., 244, 245, 246]], dtype=uint8)
    

    Once you’re done modifying the array, you can turn it back into a PIL image like this:

    >>> Image.fromarray(imarray)
    <Image.Image image mode=L size=330x44 at 0x2786518>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a python package with modules that need to open data files
Using Python I need to insert a newline character into a string every 64
Let's say I need to use Python and C++. I can call Python function
I need to convert a python code into an equivalent java code. Python makes
Is there a way to import a Python module stored in a cStringIO data
I need something like an abstract protected method in Python (3.2): class Abstract: def
A coworker left some data files I want to analyze with Numpy. Each file
I need a Python library that supports PEM files and both RSA signing and
Sometimes (in customer's PCs) I need a python script to execute in the Windows
In Python I need to efficiently and generically test whether an attribute of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.