a module about converting pngs to gif or video in simplified ways.
Project description
INTRODUCTION
convertpngs is a module to help you to do some image processing work. It is based on the opencv-python module and Pillow module, convert the multiple png files to form of gif or mp4. It is a module that CYC wrote for his own use, but I think it is useful for others, so I published it.
IMPORTANT
If you encounter the ModuleNotFoundError when using this module, you need to manually install the module in the lastest version:
pip install opencv-python
pip install Pillow
Also, some modules do not support the previous version of python, make sure you are using the version 3.7 or above.
There still exist some bugs in this module, if you find any, please contact me by email: vichouro@gmail.com . Thank you. Some function reported bugs have added the caution hint when called.
INSTALLATION
-
Install guide: (run on your powershell or cmd)
pip install convertpngs -
Update guide: (run on your powershell or cmd)
pip install --upgrade convertpngsor directly run the python script below:
from convertpngs import upgrade
USAGE
Convert pngs to gif
If you want to convert the png files to gif, you can use the function to_gif in the module convert_pngs. The function has three parameters, the first one is the input folder path, the second one is the output file name, and the third one is the duration of each frame. The default value of the third parameter is 100, which means 100 milliseconds. The function will return the path of the output file.
# 導入套件
from convertpngs import convert_pngs as cp
# 指定輸入資料夾和輸出GIF文件的名稱
input_folder = 'hotspot_TPP' # 替換PNG檔案所在的資料夾路徑
output_file = 'output.gif' # 替換為輸出的GIF檔案名稱
cp.to_gif(input_folder, output_file, duration=100, loop=0) # 每一張的顯示時間,100就是100毫秒
Convert pngs to mp4
If you want to convert the png files to mp4, you can use the function to_mp4 in the module convert_pngs. The function has three parameters, the first one is the input folder path, the second one is the output file name, and the third one is the fps of the video. The default value of the third parameter is 10, which means 10 frames per second. The function will return the path of the output file.
# 導入套件
from convertpngs import convert_pngs as cp
# 指定輸入資料夾和輸出MP4文件的名稱
input_folder = 'hotspot' # 替換為PNG檔案所在的資料夾路徑
output_file = 'output.mp4' # 替換為輸出的MP4文件名稱
cp.to_mp4(input_folder, output_file, fps=30) # 這裡的fps是幀率,可以根據需要調整
Let's all, enjoy the beauty of simplification of this module.
CHANGE LOG
0.0.1 (29/09/2023)
- First Release
0.0.3 (29/09/2023)
- Minor bug fixes
0.04 (30/09/2023)
- Fixing the bugs for displacement of the first frame of the gif
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file convertpngs-0.0.4.tar.gz.
File metadata
- Download URL: convertpngs-0.0.4.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ed94bdf0b35a2d32c8557d690b30529f29df3faa7b0ec17b63780434bab5c7a
|
|
| MD5 |
da9330b7d310da0fce5fb9e332fcab5e
|
|
| BLAKE2b-256 |
a39dc031b17ed59a37552194abab5f57ee2909837731919cdc4e3e25e8611a06
|