Skip to main content

Python image program

Project description

Pyimager

Pyimager is a python package for creating, editing and showing images with python.
It can be used to create videogames (that's why I use it for) and to many other uses.

As it is based on opencv-python but not all of these functions are implemented here, you can still use their functions with this library to get the best result of them. But still, open an issue on GitHub so I can add the functions you need.

Tutorial

Creating an image

To create an image you just need to proceed as following:

img = image(name="myImage")

You can modify the parameters of this image specifying it's size, background color and name via the following function:

img = new_img(dimensions=[200, 500], background=COL.cyan, name="myImage")
Definition for an image of 200x500 pixels with a cyan background color with "myImage" as name.

You can also import a local image:

img = image(name="myLocalImage").open_img(path)

Showing an image (until gets a keypress)

To show an image just until you get a keypress:

img.show_(0)

To add a timeout, define t as miliseconds before closing

img.show_(t)
If you want the image to be shown forever: set t to 0.

To get the key that has been pressed:

wk = img.show_(t) wk comes from WaitKey, the cv2 function used by this library.

Showing an image

To show an image, you should build it first even if you could use image.show_() to show the images without 'building' them.
So, to properly show an image, proceed as following:

img = image()
img.build()
img.show()
You could use img = image().build() too if you prefer because imag.build() returns an image.

Editing an image

To edit an image, you have to create one first:

img = image() or img = new_img()

Then, you can modify your image using the inner functions of the image class.
For drawing a diagonal line accross the image, you can do like this:

img.line(p1=[0, 0], p2=img.size(), colour=COL.red, thickness=5, lineType=2)
And like this you have a line going from p1 (0, 0) to p2 that are the coordinates of the bottom right of the image, the colour is red, the thickness of the line is 5px and, finally, the lineType is setted to 2.

You have 5 inner functions to draw shapes:

  • image.line(p1, p2, colour, thickness, lineType)
  • image.rectangle(p1, p2, colour, thickness, lineType)
  • image.circle(ct, radius, colour, thickness, lineType)
  • image.ellipse(cr, (radius1, radius2), colour, thickness, lineType, startAngle, endAngle, angle)
  • image.polygon(pts:[pt], colour, thickness, lineType)

And you have 2 inner functions more to write text:

  • image.write(text, pt, colour, thickness, fontSize, font, lineType)
  • image.write_centered(text, ct, colour, thickness, fontSize, font, lineType)

Installation

pip install python-imager

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_imager-1.2.39.tar.gz (31.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_imager-1.2.39-py3-none-any.whl (31.9 kB view details)

Uploaded Python 3

File details

Details for the file python_imager-1.2.39.tar.gz.

File metadata

  • Download URL: python_imager-1.2.39.tar.gz
  • Upload date:
  • Size: 31.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.2

File hashes

Hashes for python_imager-1.2.39.tar.gz
Algorithm Hash digest
SHA256 5a43b5f87c5ab781ab6510fc8afd4cc0ff7d63016f3bd61b147ce0719bd1c819
MD5 6b735b7c34222f5057fbfe5ed3fb1ef1
BLAKE2b-256 129c7bba170f18007992ddfc15282f77825cbe419a0b3169f07845908cfefa65

See more details on using hashes here.

File details

Details for the file python_imager-1.2.39-py3-none-any.whl.

File metadata

  • Download URL: python_imager-1.2.39-py3-none-any.whl
  • Upload date:
  • Size: 31.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.2

File hashes

Hashes for python_imager-1.2.39-py3-none-any.whl
Algorithm Hash digest
SHA256 8a1bc60947e5688b5dac660c3f230ea38b8f563703e52d3d1eed44a47e46d15b
MD5 d0b9530026502e3961d3b65cca07060e
BLAKE2b-256 8eedfa0629418144adbf1de5ca8b4e9a30a46c186a3c1eecf780c7c83a25553d

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