吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 833|回复: 13
上一主题 下一主题
收起左侧

[原创工具] python编写图片尺寸转换工具

[复制链接]
跳转到指定楼层
楼主
秋海棠地图 发表于 2025-3-10 11:52 回帖奖励

图片尺寸转换工具

这是一个使用 Python 和 Tkinter 构建的图片尺寸转换工具。用户可以选择输入图片文件,设置输出路径,并指定新的宽度和高度来调整图片尺寸。

功能

  • 选择输入图片文件
  • 设置输出路径
  • 指定新的宽度和高度
  • 预览图片
  • 调整图片尺寸并保存

依赖

  • Python 3.x
  • OpenCV (cv2)
  • Pillow (PIL)

安装

  1. 克隆或下载此项目。
  2. 安装所需的 Python 库:
    pip install opencv-python pillow

使用

  1. 运行 main.py 文件:
    python main.py
  2. 在应用程序中选择输入图片文件,设置输出路径,并指定新的宽度和高度。
  3. 点击“开始转换”按钮来调整图片尺寸并保存。

截图

![应用截图]

项目地址Github




https://www.123865.com/s/HZiDVv-szMfv提取码:52pj
链接:https://caiyun.139.com/m/i?2jQXnWmYd9dy3
提取码:mcpr
复制内容打开移动云盘PC客户端,操作更方便哦

免费评分

参与人数 2吾爱币 +8 热心值 +2 收起 理由
一场荒唐半生梦 + 1 + 1 热心回复!
风之暇想 + 7 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

推荐
 楼主| 秋海棠地图 发表于 2025-3-10 11:53 |楼主
核心代码如下
[Python] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import cv2
import os
 
# Specify the path to your image
image_path = 'logo_20250310_uugai.com_1741570805577.png'
 
# Check if the file exists
if not os.path.exists(image_path):
    print(f"Error: The file {image_path} does not exist.")
else:
    # Read the image
    image = cv2.imread(image_path)
     
    # Check if the image was successfully loaded
    if image is None:
        print(f"Error: Unable to load the image {image_path}. Please check the file integrity.")
    else:
        # Resize the image
        resized_image = cv2.resize(image, (280, 36), interpolation=cv2.INTER_AREA)
         
        # Save or display the resized image
        cv2.imwrite('resized_image.jpg', resized_image)
        print("Image resized and saved successfully.")
推荐
zrz444 发表于 2025-3-13 09:22
不知道怎么回事,用你的软件一次也没成功过。我直接用了下面的BAT文件,倒次次成功。版本不对???
pyinstaller main.py

start "" "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\dist"
4#
fxd680126 发表于 2025-3-12 06:24
5#
seamusyang 发表于 2025-3-12 08:33
能不能再加个设置 dpi ,感谢分享
6#
s849963 发表于 2025-3-12 09:02
谢谢楼主的分享,下来试试
7#
dazebat 发表于 2025-3-12 17:37
Github链接在哪里呀?
8#
一场荒唐半生梦 发表于 2025-3-12 21:02
可以批量吗?楼主?
9#
Billyphuse 发表于 2025-3-14 05:54
谢谢楼主的分享
10#
sonic0716 发表于 2025-3-14 11:55
谢谢楼主,可以提供小建议吗?就是图片能不能用拖动的方式拉到工具内
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-3-19 23:33

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表