Resize images to same size
时间: 2024-05-04 20:21:01 浏览: 34
To resize images to the same size, you can use image processing libraries such as Pillow (Python) or OpenCV (Python or C++). Here is an example using Python and Pillow:
```python
from PIL import Image
# Open the images
image1 = Image.open("image1.jpg")
image2 = Image.open("image2.jpg")
# Get their sizes
size1 = image1.size
size2 = image2.size
# Find the maximum size
max_size = max(size1, size2)
# Resize both images to the maximum size
image1_resized = image1.resize(max_size)
image2_resized = image2.resize(max_size)
# Save the resized images
image1_resized.save("image1_resized.jpg")
image2_resized.save("image2_resized.jpg")
```
This code opens two images, gets their sizes, finds the maximum size, resizes both images to the maximum size, and saves the resized images.
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)