Skip to content
This repository was archived by the owner on May 25, 2022. It is now read-only.

Commit d819e9d

Browse files
authored
Merge pull request #240 from VIPverma01/Script-to-Reduce-Image-File-Szie
Sript_to_reduce_img_size
2 parents 5e9ec79 + b5c0d7b commit d819e9d

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Script Title
2+
#### Script to reduce the size of image file using the openCV library of python.
3+
4+
### Prerequisites
5+
openCV library
6+
7+
`pip install opencv-python`
8+
9+
### How to run the script
10+
- Add the image in jpg format with name as 'input.jpg' in this folder.
11+
- Run reduce_image_size.py script.
12+
- resized output image will be generated in this folder.
13+
14+
## *Author Name*
15+
### *Vipul Verma*
603 KB
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# import openCV library for image handling
2+
import cv2
3+
4+
# read image to be resized by imread() function of openCV library
5+
img = cv2.imread('input.jpg')
6+
print(img.shape)
7+
8+
# set the ratio of resized image
9+
k = 5
10+
width = int((img.shape[1])/k)
11+
height = int((img.shape[0])/k)
12+
13+
# resize the image by resize() function of openCV library
14+
scaled = cv2.resize(img, (width, height), interpolation=cv2.INTER_AREA)
15+
print(scaled.shape)
16+
17+
# show the resized image using imshow() function of openCV library
18+
cv2.imshow("Output", scaled)
19+
cv2.waitKey(500)
20+
cv2.destroyAllWindows()
21+
22+
# get the resized image output by imwrite() function of openCV library
23+
cv2.imwrite('resized_output_image.jpg', scaled)
46.9 KB
Loading

0 commit comments

Comments
 (0)