def callOpenImageWindow(self): # Autoload the image with recommendations if self.parent.config.autoload_images: # Load a single image if self.parent.config.single_images: imageFile, _ = qtw.QFileDialog.getOpenFileName(self.parent, "Open Image(s)...", "","Image Files (*.tif;*.tiff;*.png;*.bmp;*.gif);;All Files (*)") else: imageFile = qtw.QFileDialog.getExistingDirectory(self.parent, "Open Image(s)...") if imageFile: # Get the name of the file _, _image_name = os.path.split(imageFile) # Get the recommandations image_recommendations = getImagesInfos(imageFile) _do_crop = image_recommendations['do_crop'] and self.parent.config.crop_image _crop_size = self.parent.config.crop_size _do_sign_correction = image_recommendations['do_sign_correction'] and self.parent.config.correct_signed _open_range = None _wait_range = False # Open the progress bar window openWindow(self.parent, OpenImageProgressBarWindow, 'progress_bar', image_path=imageFile, name=_image_name, crop=_do_crop, crop_size=_crop_size, correct_sign=_do_sign_correction, scheduler=self) # Add the path to the recent file list appendRecentFiles(imageFile) # Load the advanced config window else: openWindow(self.parent, openImageWindow, 'open_image')
def callOpenRecentFile(self, path=None): # Check if the file/dir exist if os.path.isdir(path) or os.path.isfile(path): # Get the name of the file _, _image_name = os.path.split(path) # Get the recommandations image_recommendations = getImagesInfos(path) _do_crop = image_recommendations['do_crop'] and self.parent.config.crop_image _crop_size = self.parent.config.crop_size _do_sign_correction = image_recommendations['do_sign_correction'] and self.parent.config.correct_signed _open_range = None _wait_range = False # Open the progress bar window openWindow(self.parent, OpenImageProgressBarWindow, 'progress_bar', image_path=path, name=_image_name, crop=_do_crop, crop_size=_crop_size, correct_sign=_do_sign_correction, scheduler=self) # Add the path to the recent file list appendRecentFiles(path) # Raise an error if the file doesn't exist anymore else: errorMessage("No Selection","The selected file or folder doesn't exist.") # Remove the file from the list deleteRecentFiles(path)
def getImageFromPath(self): # Get the name of the file _, image_name = os.path.split(self.image_path) # Get the correction to apply _do_crop = self.cropCheckBox.isChecked() _crop_size = int(self.cropSizeEntry.text()) _do_sign_correction = self.signCorrectionCheckBox.isChecked() _start, _end = self.frameRangeSelection.getRange() _open_range = _start - 1, _end # Check the crop size _proceed = True if _do_crop: if _crop_size > np.amin( [self.image_infos['size'][0], self.image_infos['size'][1]]): errorMessage( 'Cropping Error', 'The requested crop size is greater than the image size.') _proceed = False # Load the image if _proceed: self.image_class = None # Open the progress bar window openWindow(self.parent, OpenImageProgressBarWindow, 'progress_bar', image_path=self.image_path, name=image_name, open_range=_open_range, crop=_do_crop, crop_size=_crop_size, correct_sign=_do_sign_correction, scheduler=self) # Add the image to the list of recent items appendRecentFiles(self.image_path)