(self)
| 1956 | diffgram_image.width = imageio_read_image.shape[1] |
| 1957 | |
| 1958 | def resize_raw_image(self): |
| 1959 | |
| 1960 | if len(self.raw_numpy_image.shape) == 3: |
| 1961 | channels = self.raw_numpy_image.shape[2] |
| 1962 | if channels == 4: |
| 1963 | # Careful, if black and white this will fail (hence only running if 4 channels) |
| 1964 | self.raw_numpy_image = self.raw_numpy_image[:, :, :3] # remove alpha channel |
| 1965 | |
| 1966 | if self.raw_numpy_image is None: |
| 1967 | raise IOError("Could not open") |
| 1968 | |
| 1969 | self.get_and_set_width_and_height( |
| 1970 | diffgram_image = self.new_image, |
| 1971 | imageio_read_image = self.raw_numpy_image) |
| 1972 | |
| 1973 | max_size = settings.DEFAULT_MAX_SIZE |
| 1974 | |
| 1975 | if self.new_image.height > max_size or self.new_image.width > max_size: |
| 1976 | ratio = min((max_size / self.new_image.height), |
| 1977 | (max_size / self.new_image.width)) |
| 1978 | |
| 1979 | shape_x = int(round(self.new_image.width * ratio)) |
| 1980 | shape_y = int(round(self.new_image.height * ratio)) |
| 1981 | |
| 1982 | self.raw_numpy_image = imresize(self.raw_numpy_image, |
| 1983 | (shape_x, shape_y)) |
| 1984 | |
| 1985 | self.get_and_set_width_and_height( |
| 1986 | diffgram_image = self.new_image, |
| 1987 | imageio_read_image = self.raw_numpy_image) |
| 1988 | |
| 1989 | def process_csv_file(self): |
| 1990 | """ |
no test coverage detected