woodmastr commited on
Commit
d87a006
·
verified ·
1 Parent(s): 386603a

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +117 -0
README.md CHANGED
@@ -9,5 +9,122 @@ app_file: app.py
9
  pinned: false
10
  license: apache-2.0
11
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
9
  pinned: false
10
  license: apache-2.0
11
  ---
12
+ # IMAGER ___ Image Processing Script
13
+
14
+ This Python script offers a versatile image processing toolkit, allowing for operations such as background removal, autocropping, resizing, and adding padding to images. It's designed to process images in bulk, making it an ideal solution for preparing images for web use or personal projects.
15
+
16
+ ## Features
17
+
18
+ - **Background Removal**: Automatically removes the background from images.
19
+ - **Autocropping**: Crops images to remove unnecessary transparent space.
20
+ - **Resizing**: Resizes images to specified dimensions, maintaining aspect ratio.
21
+ - **Padding**: Adds padding around images, ensuring the final image size matches specified dimensions.
22
+
23
+ ## Installation
24
+
25
+ To run this script, you'll need Python installed on your system along with the following packages:
26
+ - Pillow
27
+ - rembg
28
+
29
+ You can install the required packages using pip:
30
+
31
+ ```sh
32
+ pip install Pillow rembg
33
+ ```
34
+
35
+ # CLI Usage imager.py
36
+
37
+ Place the images you want to process in the ./input directory. The CLI command is intended for bulk processing. Run the script with desired options:
38
+
39
+ ```sh
40
+ python imager.py -b -c -r 800x600 -p 10
41
+ ```
42
+
43
+ ## Command-Line Arguments
44
+
45
+ - `-b, --background_removal`: Enable background removal.
46
+ - `-c, --crop`: Enable autocropping.
47
+ - `-r, --resize AxB`: Resize the image to fit within AxB pixels, maintaining aspect ratio.
48
+ - `-p, --padding PIXELS`: Add PIXELS number of padding around the image. The final image size stays as specified in `-r AxB`.
49
+ - `-bg, --background BACKGROUND`: Add a background to the image. Accepts color names, hex codes, or paths to image files.
50
+
51
+ ## Example
52
+ To process images by removing the background, autocropping, resizing to 800x600 pixels, and adding 10 pixels of padding:
53
+
54
+ ```sh
55
+ python imager.py -b -c -r 320x280 -p 10
56
+ ```
57
+
58
+ This command processes all images in the ./input directory and saves the processed images to the ./output directory.
59
+
60
+ Super Mario and Fujicamera automatically converted by imager.py: bg_removed, cropped and skaled to 320x280.
61
+
62
+ <img src="data/examples/supermario.png" alt="alt text" width="200" style="border: 1px solid white;">
63
+ <img src="data/examples/supermario_b_c320x280.png" alt="alt text" width="200" style="border: 1px solid white;">
64
+
65
+ <img src="data/examples/depositphotos_520707962-stock-photo-fujifilm-s10-body-black-fujifilm.jpg" alt="alt text" width="200" style="border: 1px solid white;">
66
+ <img src="data/examples/depositphotos_520707962-stock-photo-fujifilm-s10-body-black-fujifilm_b_c320x280.png" alt="alt text" width="200" style="border: 1px solid white;">
67
+
68
+
69
+ ### Adding a background
70
+
71
+ Let's add a blue and a green and blue background.
72
+
73
+ ```sh
74
+ python imager.py -b -c -r 320x280 -p 10 -bg green
75
+ ```
76
+ <img src="data/examples/batman_b_c_320x280_bg.png" alt="alt text" width="200" style="border: 1px solid white;">
77
+ <img src="data/examples/supermario2_b_c_320x280_bg.png" alt="alt text" width="200" style="border: 1px solid white;">
78
+
79
+
80
+ ## Background Colors
81
+
82
+ Grayscale Monochrome Color Palette: This palette consists of different shades of gray, from light to dark, creating a simple yet effective look. The hex codes are:
83
+
84
+ | Color Name | Hex Code |
85
+ |----------------|----------|
86
+ | Light Gray | #D1D1D3 |
87
+ | Lavender Gray | #C6C6C7 |
88
+ | Silver Foil | #AFAFB0 |
89
+ | Quick Silver | #A4A4A5 |
90
+ | Spanish Gray | #999999 |
91
+
92
+ Feminine Soft Neutrals: This palette features warm and cozy tones, such as sand, orange, and pink, creating an inviting atmosphere. The hex codes are:
93
+
94
+ | Color Name | Hex Code |
95
+ |---------------|----------|
96
+ | Alabaster | #F4EEE1 |
97
+ | Dark Vanilla | #C4BDAC |
98
+ | Dust Storm | #EBCFC4 |
99
+ | Pale Silver | #D3C4BE |
100
+ | Desert Sand | #E9CCB1 |
101
+
102
+
103
+ Neutral Brown Color Palette: This palette offers a rich range of brown tones, from deep and dark to light and delicate, creating a sense of stability and warmth. The hex codes are:
104
+
105
+ | Color Name | Hex Code |
106
+ |-----------------|----------|
107
+ | Café Noir | #4E3829 |
108
+ | Coffee | #6B513E |
109
+ | Beaver | #8E7766 |
110
+ | Khaki | #B09C8D |
111
+ | Champagne Pink | #E6D7CE |
112
+
113
+ # Gradio App gradio_imager.py
114
+
115
+ start the gradio app with the below command. the app can handle only one image at a time.
116
+ ```sh
117
+ python gradio_imager.py
118
+ ```
119
+
120
+ ![gradio app](data/gradioimager2.png)
121
+
122
+ # License
123
+ This project is open-source and available under the MIT License.
124
+
125
+ ## Contributing
126
+
127
+ Contributions to improve the script or add new features are welcome. Please feel free to fork the repository and submit pull requests.
128
+
129
 
130
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference