You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This app is responsible for handling image processing and transformations.
4
4
5
-
## Core Concepts
5
+
## Core concepts
6
6
7
7
-**Image Transformations**: Provides capabilities to transform images in various ways and provide different processing strategies.
8
8
-**Transformation Management**: Provides a high-level interface for general image operations.
9
9
-**Transformers**: Define different strategies for applying transformations, such as in parallel or one by one.
10
10
-**Detectors**: Detect objects in images using computer vision models.
11
11
12
-
## Key Components
12
+
## Key components
13
13
14
14
-**`transformations.py`**: Applies a transformation to an image using the Pillow (PIL) library and returns a transformed PIL image copy.
15
15
-**`transformers.py`**: Defines different strategies for applying transformations.
@@ -18,88 +18,87 @@ This app is responsible for handling image processing and transformations.
18
18
-`ImageChainTransformer`: Applies transformations sequentially, where the output of one transformation becomes the input for the next.
19
19
-**`managers.py`**: Manages the overall image processing workflow.
20
20
-`ImageLocalManager`: Manages transformations for images stored locally on the filesystem. It opens the image, applies transformations using a specified transformer, and saves the resulting images to a structured directory.
21
-
-**`data_models.py` (within `src/`)**: Defines internal data structures used during the transformation process, such as `InternalImageTransformationFilters` which are direct mappings to PIL's internal representations.
22
21
23
-
## How it Works (Example Flow from `apps.places.tasks.py`)
22
+
## How is expected to be used:
24
23
25
-
The `transform_uploaded_images` task in `apps.places.tasks.py` demonstrates how this `image_processing` app is used:
26
-
27
-
1. A list of `ImageTransformationDefinition` objects is defined, each specifying an `identifier`, a `transformation` type (e.g., `ImageTransformations.THUMBNAIL`), and optional `filters`.
24
+
1. Define a list of transformation objects is defined, each specifying an `identifier`, a `transformation` name type (e.g., `thumbnail`), and optional `filters`.
28
25
```python
29
-
from apps.image_processing.api.constants import (
30
-
ImageTransformations,
31
-
TransformationFilterBlurFilter,
32
-
TransformationFilterDither,
33
-
TransformationFilterThumbnailResampling,
34
-
)
35
-
from apps.image_processing.api.data_models import (
2. Use the `image_local_transform` service with the `image_path`, the list of `transformations`, and a `parent_folder` name.
46
+
2. Use the `image_processing_transform` function to apply transformations to an image, specifying the `user_id`, `image_path`, `transformations`, `parent_folder` (optional), and `chain` (optional).
75
47
```python
76
-
from apps.image_processing.api.services.processing import image_local_transform
77
-
78
-
applied_transformations = image_local_transform(
79
-
user_id=request.user.id,
80
-
image_path="path/to/local/image.png",
48
+
from apps.image_processing.models import (
49
+
ProcessingImage,
50
+
)
51
+
from apps.image_processing_api.services import image_processing_transform
The core logic for applying custom image transformations. This includes the actual transformation logic using the Pillow (PIL) library. They take an image, apply a transformation based on the provided filters, and return a transformed PIL image copy.
96
71
97
-
Make your own transformation like this:
72
+
Make your own transformation like this and create the corresponding filters interfaces:
98
73
```python
99
-
from apps.image_processing.src.data_models import InternalImageTransformation
Defines the internal representations of image transformations. Each subclass corresponds to a specific transformation type and its associated filters.
124
+
Each transformation has its own set of filters, which are defined in the `ExternalTransformationFilters` interface. These filters are used to specify the parameters for the transformation.
126
125
127
-
Make your own filters like this:
128
-
```python
129
-
from apps.image_processing.src.data_models import InternalImageTransformationFilters
130
-
131
-
@dataclass
132
-
classInternalTransformationFiltersCrop(InternalImageTransformationFilters): # Inherit from InternalImageTransformationFilters
133
-
x_left: float
134
-
y_top: float
135
-
x_right: float
136
-
y_bottom: float
137
-
```
126
+
The `ExternalTransformationFilters` implementations must be able to be converted to the corresponding `InternalImageTransformationFilters` implementations using the `to_internal` method.
0 commit comments