I want to read a bitmap that represents a sprite, and crop a part of it.
Here is an example of an image.

In Matlab I would have done somethings like:
i = imread('myfile.png')
x1 = i(1:64,1:64,:)
How can I do the same in python?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
PIL could do that,
cropfunction in particular.I’m not sure, seems like your image uses palette? I added
convertto RGBA call so output file has transparency. Withoutconvertfile has green (why green?) color on transparent pixels.