Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 849d761

Browse files
Merge pull request avinashkranjan#2027 from Tisha6661/Resize-Image
Resize image
2 parents a6e07f5 + 5e0da76 commit 849d761

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

‎Rescale Image/README.md‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Resize Images
2+
3+
To resize the width and height of the image.
4+
5+
## Setup instructions
6+
7+
To set up and run the script, follow the instructions below:
8+
9+
1. Install the required dependencies:
10+
- `cv2`
11+
12+
4. Run the script:
13+
- Execute the script using a Python interpreter.
14+
15+
## Detailed explanation of script
16+
17+
The script performs the following steps:
18+
19+
1. Imports the necessary libraries (`cv2`).
20+
2. Take an image named 'input_image.jpg'.
21+
4. Execute the script, you will see the output_image.jpg file generated by the script which is resized.
22+
23+
## Output
24+
25+
The script saves the generated output image as "output_image.jpg" in the current directory which contains the resized image.
26+
27+
## Author(s)
28+
29+
Author: [Tisha Garg](https://github.com/Tisha6661)
30+

‎Rescale Image/input_image.jpg‎

31.8 KB
Loading[フレーム]

‎Rescale Image/output_image.jpg‎

10.5 KB
Loading[フレーム]

‎Rescale Image/resize_image.py‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import cv2
2+
3+
def resize_image(input_image, output_image, new_width, new_height):
4+
# Read the input image
5+
image = cv2.imread(input_image)
6+
7+
# Resize the image
8+
resized_image = cv2.resize(image, (new_width, new_height))
9+
10+
# Save the resized image
11+
cv2.imwrite(output_image, resized_image)
12+
13+
print("Image resized and saved successfully!")
14+
15+
# Display the original image
16+
cv2.imshow('Original Image', image)
17+
cv2.waitKey(0)
18+
19+
# Display the resized image
20+
resized_image = cv2.imread(output_image)
21+
cv2.imshow('Resized Image', resized_image)
22+
cv2.waitKey(0)
23+
cv2.destroyAllWindows()
24+
25+
# Specify the input image path, output image path, and new dimensions
26+
input_image_path = 'input_image.jpg'
27+
output_image_path = 'output_image.jpg'
28+
new_width = 300
29+
new_height = 150
30+
31+
# Resize the image
32+
resize_image(input_image_path, output_image_path, new_width, new_height)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /