Previously review: previous article
16th off Address
Open 16 off, but also a strange and many points of the picture, it should be related to the PIL library.
The title of the page is: Let me get the this straight. This is a slang term in English, which means let me make it clear. In this gateway is actually let us put the pixel position of each line after adjusting to it.
Look at this picture, a lot of red dots, and then think of these dots are not what the pixel is special, the pixel value of each row is printed out and found that each row has a continuous 5 pixel value of 195.
It then shifts the pixels of each row, moves the pixel value 195 to the leftmost, and then gets a new picture of it. The following:
That is, the URL of the next pass.
The code is as follows:
1 Importurllib.request as ur2 fromPILImportImage3 4 defMain ():5im = Image.open ("Mozart.gif")6(width,height) =im.size7mode =Im.mode8 Print(Mode)9 Print(im.size)Ten OneImanswer =image.new (mode, (width,height)) A - forYinchRange (height): -pixels = [Im.getpixel ((x, y)) forXinchrange (width)] the Print(pixels) - -x = Pixels.index (195) -Newpixels = Pixels[x:width] +Pixels[:x] + - forXinchRange (width): + Imanswer.putpixel ((x, y), newpixels[x]) A atImanswer.save ('16answer.gif') - - - if __name__=='__main__': -Main ()
Python Challenge 16