Skip to main content

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 convertpngs

    or 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_png. 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_png.to_gif

# 指定輸入資料夾和輸出GIF文件的名稱
input_folder = 'hotspot_TPP'  # 替換PNG檔案所在的資料夾路徑
output_file = 'output.gif'  # 替換為輸出的GIF檔案名稱
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_png. 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_png.to_mp4

# 指定輸入資料夾和輸出MP4文件的名稱
input_folder = 'hotspot'  # 替換為PNG檔案所在的資料夾路徑
output_file = 'output.mp4'  # 替換為輸出的MP4文件名稱
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.2 (29/09/2023)

  • Minor bug fixes

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

convertpngs-0.0.2.tar.gz (4.9 kB view details)

Uploaded Source

File details

Details for the file convertpngs-0.0.2.tar.gz.

File metadata

  • Download URL: convertpngs-0.0.2.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for convertpngs-0.0.2.tar.gz
Algorithm Hash digest
SHA256 5533abcaa2a93bd4e4a82c53044262bdd5f4d8e23ae39c1bc97ee68c40c992ff
MD5 9bae53a5fe7541c8965d2754c5c612ec
BLAKE2b-256 f6692a178812446abf73e37846f4e85cf7dde827c4bc8d3ddb4c2decbc47c807

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page