2013年2月20日 星期三

取得圖檔大小


  1. 安裝PIL模組。  
  2. 加入下面程式碼。

from PIL import Image
 
# pick an image file you have in the working directory
# (or give full path name)
image_file = "D:\My Documents\My Pictures\Costa Rican Frog.jpg"
img = Image.open(image_file)
# get the image's width and height in pixels
width, height = img.size
print width
print height

沒有留言: