Skip to main content

No project description provided

Project description

A simple image resizing CLI - PyPi package deployment CI example

About

This project is used as an example of how to deploy a Python package to PyPi using GitHub Actions. The example package is a simple CLI tool I built many moons ago that allows you to easily resize any image file from the command line. Feel free to use this if you think it would be useful but you're probably better off with ImageMagick.

Installation

pip install resize-img

Commands

  • resize-img $IMG_PATH Saves a new, resized image of the specified image path to the CWD, using the default size of 512x512px.
  • resize-img $IMG_PATH small Saves specified image as 250x250px in CWD.
  • resize-img $IMG_PATH medium Saves specified image as 1000x1000px in CWD.
  • resize-img $IMG_PATH big Saves specified image as 2000x2000px in CWD.
  • resize-img $IMG_PATH custom <int> <int> Saves specified image as pxpx in CWD.
  • resize-img --help Prints the CLI instructions to your terminal.

Deploy your own PyPi package with GitHub Actions

Prerequisites:

Setup instructions

Examples of each of the following steps can be found in this repository in the referenced locations.

  1. Add your PyPi username as password to a GitHub repo's environment as secrets.
  2. Package the code you want to deploy into a folder (the package in this example is called img_resizer).
  3. Create a file named __init__.py in your package and import the main function for your package.
  4. Create a file named setup.py in the root folder of your project. In this file, you specify the name of the PyPi package and any CLI entry points. Package requirements and markdown description can also be specified if you want this to show on the PyPi platform, see mine for example.
  5. Create a GitHub Actions workflow to trigger your desired event that will build your package with the wheel library and upload your package using the twine library. Your PyPi username and password secrets will need to be set as environment variables for this to work (see my example).
  6. update your project repo in GitHub to trigger your workflow and upload your package to PyPi. This will then be easily installable on any machine with the command pip install <package name>

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

resize_img-0.7.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

resize_img-0.7-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file resize_img-0.7.tar.gz.

File metadata

  • Download URL: resize_img-0.7.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for resize_img-0.7.tar.gz
Algorithm Hash digest
SHA256 2da6d100b7fb411ff3dd262edb0e6f0a8a4d1b141c164491485467d2a5bc97c7
MD5 06408faeed2e8b1022a3409fd7f50b1a
BLAKE2b-256 d16067892a25f156f2a605c91b4dad6a9192859402ac980b3f688e983afec6c6

See more details on using hashes here.

File details

Details for the file resize_img-0.7-py3-none-any.whl.

File metadata

  • Download URL: resize_img-0.7-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for resize_img-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 bf2ce7ed67df019713fb80bbe68526cc47683bb6b1dbcc0338bf77524e7d13e6
MD5 8c07104706b9d2f40f3dcc237f60f86e
BLAKE2b-256 688941a9c2e63845df84f6ccd50a1c21dea9bbbe148b203982486e98882b8ead

See more details on using hashes here.

Supported by

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