text_plain_output_1.png image_output_1.png
from PIL import Image

from PIL import ImageOps

import matplotlib.pyplot as plt

import numpy as np

import numpy as np # linear algebra

from PIL import Image
image = Image.open('../input/pilimages/opera_house.jpg')

import matplotlib.pyplot as plt
import numpy as np
img_arr = np.asarray(image)

img = Image.fromarray(img_arr)

image.save('opera_house.png', format='PNG')

new_img = Image.open('./opera_house.png')

from PIL import ImageOps
gray_img = ImageOps.grayscale(new_img)
gray_img_arr = np.asarray(gray_img)

"""
Current image dim width x height (640,360). thumbnail will resize the bigger dim i.e 640 to 100
and other dim will be rescaled to maintain aspect ratio.
Standard resampling algorithms are used to invent or remove pixels when resizing, and you can specify
a technique, although default is a bicubic resampling algorithm that suits most general applications
"""
new_img.thumbnail((100, 100))

hoz_flip = image.transpose(Image.FLIP_LEFT_RIGHT)
ver_flip = image.transpose(Image.FLIP_TOP_BOTTOM)

"""
In both rotations, the pixels are clipped to the original dimensions of the image
and the empty pixels are filled with black color.
"""

"""
here we created a cropped square image of 100 pixels starting at 100,100 and
extending down and left to 200,200.
"""
cropped_img = image.crop((100, 100, 200, 200))

image = Image.open('../input/bridge-image/sydney_bridge.png')

plt.imshow(image)