title: Open process and save specific images in related folder
body: <p>I'm looking for a way to open and crop several tiff images and then save the new croped images created in the same folder (related to my script folder).</p>
  
  <p>My current code looks like this:</p>
  
  <pre><code>from PIL import Image
  import os,platform
  
  filespath = os.path.join(os.environ['USERPROFILE'],"Desktop\Python\originalImagesfolder")
  
  for file in os.listdir(filespath):
      if file.endswith(".tif"):
          im = Image.open(file)
          im.crop((3000, 6600, 3700, 6750)).save(file+"_crop.tif")
  </code></pre>
  
  <p>This script is returning me the error:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):   </p>
    
    <p>File "C:\Users...\Desktop\Python\script.py", line 22, in
    
        im = Image.open(file)<br>
    File "C:\Python34\lib\site-packages\PIL\Image.py", line 2219, in open
        fp = builtins.open(fp, "rb") 
    FileNotFoundError: [Errno 2] No such file or directory: 'Image1Name.tif'</p>
  </blockquote>
  
  <p>'Image1Name.tif' is the first tif image I'm trying to process in the folder. I don't get how the script can give the file's name without being able to find it. Any Help?</p>
  
  <p>PS: I have 2 days experience in python and codes generaly speaking. Sorry if the answer is obvious</p>
  
  <p><strong>[EDIT/Update]</strong>
  After modifying my initial code thanks to vttran and ChrisGuest answers, turning then into this:</p>
  
  <pre><code>from PIL import Image
  import os,platform
  
  filespath = os.path.join(os.environ['USERPROFILE'],"Desktop\Python\originalImagesfolder")
  
  for file in os.listdir(filespath):
      if file.endswith(".tif"):
          filepath = os.path.join(filespath, file)
          im = Image.open(filepath)
          im.crop((3000, 6600, 3700, 6750)).save("crop"+file)
  </code></pre>
  
  <p>the script is returning me a new error message:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):<br>
    File "C:/Users/.../Desktop/Python/script.py", line 11, in
    
        im.crop((3000, 6600, 3700, 6750)).save("crop"+file)<br>
    File "C:\Python34\lib\site-packages\PIL\Image.py", line 986, in crop
        self.load()<br>
    File "C:\Python34\lib\site-packages\PIL\ImageFile.py", line 166, in load
        self.load_prepare()<br>
    File "C:\Python34\lib\site-packages\PIL\ImageFile.py", line 250, in
    load_prepare
        self.im = Image.core.new(self.mode, self.size) ValueError: unrecognized mode</p>
  </blockquote>
  
  <p>A maybe-useful information, it's a Landsat8 image in GeoTiff format. The TIFF file therefore include geoposition, projection... informations. The script works perfectly fine if I first open and re-save them with a software like Photoshop (16int tiff format).</p>