title: check the width and height of an image
body: <p>i am trying to check the width and height of an image in a directory by using python . the directory consist of two folders and each folder there are pictures want to check the width and height to resize them if they are not matched. here is my code:</p>
  
  <pre><code>def Resize(imageFolder, factor_1, factor_2):
  
  
      for path, dirs, files in os.walk(imageFolder):
         for fileName in files:
  
           image = Image.open(fileName)
           image_size = image.size
           width = image_size[0]
           height = image_size[1]
           if ((width and height) == 224):
              print("the width and height are equals")
  
              continue
           print("the width and height are not equals, so we should resize it")    
          resize_pic(path, fileName, factor_1, factor_2)
  </code></pre>
  
  <p>when I run the code gives me error, i think the loop is not right. any help ? </p>
  
  <pre><code> Traceback (most recent call last):
  
   File "resize.py", line 62, in &lt;module&gt;
   Resize(imageFolder, resizeFactor , resizeFactor_h)
  
   File "resize.py", line 46, in Resize
     image = Image.open(fileName)
  
   File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 2028, in open
  
   raise IOError("cannot identify image file")
  
   IOError: cannot identify image file
  </code></pre>