Skip to content

Commit 21ec245

Browse files
committed
Added image manipulation script
1 parent efbe1e0 commit 21ec245

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

File Downloader Script/README.md

Whitespace-only changes.

Image Manipulation Script/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# File Downloader Script
2+
3+
4+
The script provided earlier is an "Image Manipulation Script" written in Python using the Pillow library. It allows you to perform basic image manipulations such as resizing, rotating, and flipping an image.
5+
6+
The script consists of three main functions:
7+
8+
-resize_image(): Resizes an input image to a specified size.
9+
-rotate_image(): Rotates an input image by a specified number of degrees.
10+
-flip_image(): Flips an input image based on a specified flip mode.
11+
12+
<br>
13+
14+
## Instructions 📝
15+
16+
### Step 1:
17+
18+
Save the Script: Save the script code provided earlier in a file with the desired name, such as image_manipulation.py. Make sure to save it with the .py extension, indicating that it is a Python script.
19+
### Step 2:
20+
21+
Install Dependencies: Ensure that you have the necessary dependencies installed. In this case, the script relies on the Pillow library. You can install it using the pip package manager. Open a command prompt or terminal and run the following command:
22+
23+
pip install Pillow
24+
25+
### Step 3:
26+
Run the Script: Open a command prompt or terminal, navigate to the directory where the script is saved, and run the following command:
27+
python image_manipulation.py
28+
29+
### Step 4:
30+
31+
Check the Output: The script will perform the specified image manipulations based on the example usage section. The resized, rotated, and flipped images will be saved to the specified output file paths. You will see success messages for each manipulation indicating that the images have been processed and saved successfully.
32+
33+
34+
<br>
35+
36+
<hr>
37+
38+
> **Warning**
39+
>
40+
>Remember to update the file paths and manipulation parameters in the example usage section to match your specific needs.
41+
42+
Ensure that you have the Pillow library installed (pip install Pillow) before running the script.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from PIL import Image
2+
3+
def resize_image(input_image, output_image, new_size):
4+
image = Image.open(input_image)
5+
resized_image = image.resize(new_size)
6+
resized_image.save(output_image)
7+
print("Image resized and saved successfully.")
8+
9+
def rotate_image(input_image, output_image, degrees):
10+
image = Image.open(input_image)
11+
rotated_image = image.rotate(degrees)
12+
rotated_image.save(output_image)
13+
print("Image rotated and saved successfully.")
14+
15+
def flip_image(input_image, output_image, flip_mode):
16+
image = Image.open(input_image)
17+
flipped_image = image.transpose(flip_mode)
18+
flipped_image.save(output_image)
19+
print("Image flipped and saved successfully.")
20+
21+
# Example usage: Resize, rotate, and flip an image
22+
input_file = 'input_image.jpg'
23+
resized_file = 'resized_image.jpg'
24+
rotated_file = 'rotated_image.jpg'
25+
flipped_file = 'flipped_image.jpg'
26+
27+
new_size = (800, 600)
28+
degrees_to_rotate = 90
29+
flip_mode = Image.FLIP_LEFT_RIGHT
30+
31+
resize_image(input_file, resized_file, new_size)
32+
rotate_image(input_file, rotated_file, degrees_to_rotate)
33+
flip_image(input_file, flipped_file, flip_mode)

SCRIPTS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,5 @@
9797
| 93\. | Queue | Queue scripts in Python is to allow efficient handling of elements in a sequence according to the FIFO rule. | [Take Me](./Queue/) | [Himanshu Agarwal](https://github.com/himanshu-03)
9898
|94\. | Linked List | Linked List data Scripts are used to store and manage a collection of elements in a dynamic and flexible manner | [Take Me](./Linked%20List/) | [Himanshu Agarwal](https://github.com/himanshu-03)
9999
| 95\. | Searching Techniques | Searching techniques are scripts used to find a specific element or value within a collection of data. | [Take Me](./Searching%20Techniques/) | [Himanshu Agarwal](https://github.com/himanshu-03)
100-
| 96\. | Sorting Techniques | Sorting techniques are scripts that arrange a collection of data elements in a particular order, typically ascending or descending. | [Take Me](./Sorting%20Techniques/) | [Himanshu Agarwal](https://github.com/himanshu-03)
100+
| 96\. | Sorting Techniques | Sorting techniques are scripts that arrange a collection of data elements in a particular order, typically ascending or descending. | [Take Me](./Sorting%20Techniques/) | [Himanshu Agarwal](https://github.com/himanshu-03)
101+
| 98\. | | The script provided earlier is an "Image Manipulation Script" written in Python using the Pillow library. It allows you to perform basic image manipulations such as resizing, rotating, and flipping an image.. | [Take Me](./Image Manipulation Script/) | [Himanshu Agarwal](https://github.com/Abhinavcode13)

0 commit comments

Comments
 (0)