Task/ie 8/ie 13/flip image - #8
Conversation
# Conflicts: # .gitignore # image_editor/core/image_processing/Image_Processing.py # image_editor/test/test.py # image_editor/utils/convert_image.py # requirements.txt # test_image.py
There was a problem hiding this comment.
Don't remove these files output/sample_image/OPIMG_1.png this will not check-in output file directory.
I have added a gitignore file in this commit 8b518dd
| # virtualenv | ||
| env/ | ||
| venv/ | ||
| whlenv/ No newline at end of file |
There was a problem hiding this comment.
@DhimanGhosh can we have like *env ? then all the env files folders will be
And do we really need to have this as we have this already handled?

So a blank folder will never be checked in
| RED_CHANNEL = 0 | ||
| GREEN_CHANNEL = 1 | ||
| BLUE_CHANNEL = 2 |
There was a problem hiding this comment.
Can this be done like this
class ColorChannel:
Red, Green, Blue = range(3)Similarly for the other two different enum classes?
https://stackoverflow.com/a/702903
| CROP_CUSTOM = 0 | ||
| CROP_1_1 = 1 | ||
| CROP_CIRCLE = 2 | ||
|
|
||
| # Flip Directions | ||
| FLIP_VERTICAL = 0 | ||
| FLIP_HORIZONTAL = 1 | ||
| FLIP_VERTICAL_HORIZONTAL = 2 |
| from image_editor.core.image_processing.interface.Image_Processing_Abstract import ImageProcessingAbstract | ||
| from image_editor.utils.convert_image import image_to_numpy_array, numpy_array_to_image, transparent_background | ||
| from glob import glob | ||
| from image_editor.utils.convert_image import image_to_numpy_array, numpy_array_to_image, transparent_background, cv_to_image |
There was a problem hiding this comment.
Can we follow this coding standard ?
https://stackoverflow.com/a/29193752
from module import xx still occurs sometimes in my code. I use it in cases where even the as format appears exaggerated, the most famous example being from datetime import datetime (but if I need more elements, I will import datetime as dt).
Suggestion would be like this import image_editor.utils.convert_image as ieuc
| new_img[:, :, [1, 2]] = 0 | ||
| if channel.lower() == 'g': | ||
| if channel == ie.GREEN_CHANNEL: | ||
| new_img[:, :, [0, 2]] = 0 |
There was a problem hiding this comment.
Is this correct? because we need just one color channel and not two ?
And one more suggestion can the ENUM be designed like a index ?
new_img[:, :, color_channel_enum], then no need of if-else
| elif kwargs.get('aspect_ratio', '1:1') == '1:1': | ||
| shift = kwargs.get('dimension', 0) | ||
| elif aspect_ratio == ie.CROP_1_1: | ||
| shift = kwargs.get('shift', 0) |
There was a problem hiding this comment.
shift can it be made a constant, and all the expected KWARGS be made as a constant?
like aspect_ratio, amount , direction ...
| if flip_direction == ie.FLIP_VERTICAL: | ||
| img = cv.flip(img, 0) | ||
| elif flip_direction == ie.FLIP_HORIZONTAL: | ||
| img = cv.flip(img, 1) | ||
| elif flip_direction == ie.FLIP_VERTICAL_HORIZONTAL: | ||
| img = cv.flip(img, -1) |
There was a problem hiding this comment.
Can the enum value be made as a third param to cv.flip
| if flip_direction == ie.FLIP_VERTICAL: | |
| img = cv.flip(img, 0) | |
| elif flip_direction == ie.FLIP_HORIZONTAL: | |
| img = cv.flip(img, 1) | |
| elif flip_direction == ie.FLIP_VERTICAL_HORIZONTAL: | |
| img = cv.flip(img, -1) | |
| img = cv.flip(img, flip_direction) |
| list_of_files = Path(dirname).glob(f'*.{extension}') | ||
| seq_no = max([0] + [int(Path(fn).stem.split('_')[1]) for fn in list_of_files if '_' in Path(fn).stem]) | ||
| new_file_path = dirname + os.sep + f'OPIMG_{seq_no + 1}.{extension}' |
There was a problem hiding this comment.
Can this be made common ? as this is used above also
This pull request is linked with the issue: IE-13
Description:
Added support for flipping the image horizontally or vertically
Checklist: