def create_temp_crops(self):
     '''
     This methods creates cropped tif-files for the deskew selector. This 
     because the deskew may function better, if margins are removed beforehand.    
     
     The cropped tif files are placed in the temp folder and the paths to these
     are placed in the img_info for the deskew funtion to use.
     '''
     image_paths = sorted(self.img_proc_info['images'].keys())
     for image_path in image_paths:
         file_name = os.path.basename(image_path)
         file_name,_ = os.path.splitext(file_name)
         dest = os.path.join(self.temp_folder,file_name+'.tif')
         info = self.img_proc_info['images'][image_path]
         image_tools.cropImage(image_path,self.temp_folder,info,dest,to_tif=True)
         self.img_proc_info['images'][image_path]['image_for_deskew'] = dest 
 def processFile(self,file_path,info):
     time_stat = {}
     file_name,_ = os.path.splitext(os.path.basename(file_path.rstrip(os.sep)))
     if self.debug: self.logger.debug('File: {0}'.format(file_name))
     if info['crop']:
         #===================================================================
         # Crop image with coordinates, if cropping is turned on
         #===================================================================
         if self.debug: self.logger.debug('\tCrop image')
         t = time.time()
         file_path = image_tools.cropImage(file_path,self.temp_folder,info)
         time_stat['Crop image'] = time.time()-t
     
     if info['deskew']:
         #===================================================================
         # Deskew image, if deskew is turned on
         #===================================================================
         if self.debug: self.logger.debug('\tDeskew image')
         t = time.time()
         # Jeg har sat quality til 50% så de ikke fylder så meget når jeg skal gemme de resulterende jpgs til OCR
         file_path = image_tools.deskewImage(file_path,self.temp_folder,
                                             info['deskew_angle'],quality=50,
                                             resize=self.settings['output_resize'])
         time_stat['Deskew image'] = time.time()-t
     else:
         if self.debug: self.logger.debug('\tNo deskewing')
         t = time.time()
         file_name,_ = os.path.splitext(os.path.basename(file_path))
         dest = os.path.join(self.temp_folder,file_name+'compressed.jpg')
         image_tools.compressFile(file_path,dest,quality=50,
                                  resize=self.settings['output_resize'])
         file_path = dest
         time_stat['Compress/resize image'] = time.time()-t
     # 3: to pdf 
     if self.debug: self.logger.debug('\tConvert image to pdf files')
     t = time.time()
     if self.settings['output_images']: shutil.copy2(file_path,self.output_image_location)
     if self.settings['output_pdf']:
         output_pdf = os.path.join(self.temp_pdf_folder,file_name+'.pdf')
         image_tools.compressFile(file_path,output_pdf)
     time_stat['Convert to pdf'] = time.time()-t
     return time_stat