aboutsummaryrefslogtreecommitdiff

Image RGBA

Characteristics

  • Separates the RGBA values of a photograph to separate ones
  • Joins separated RGBA images to from a single one

Support

  • Script-Interface (Python required)
  • Tested Python: 2.7.11, 3.2.5
  • Tested O.S: Windows 10

Image

Notes

History

The project itself I can not remember how it started, or what lead me to it, but maybe someone will find it useful (or some part of the code for some project). Followed by this paragraph I attach the description I did at the time of its creation, this is also included in the source code of the project.

This module separates the RGBA values for an image to different ones and if given them it can rejoin the to produce the original file. PyGame surfaces or file names are supported in exchange, you can mix them, it is not necessary to use one type in the same function if it asks for image input.

The module will separated the RGBA values to different images, as it uses PyGame you can either use a filename or surface if you already have it loaded. Also the output of it can be change to create new photos or return surface, this applies to the separation of the colour values or joining of them.

Utilization

Separating colour values

#RETURN RGBA PYGAME SURFACES FROM PYGAME SURFACE
rgba_surfaces = Split(original_surface,False)

#RETURN RGBA PYGAME SURFACES FROM FILE
rgba_surfaces = Split("file_name.extension",False)

#SAVE RGBA FILES FROM PYGAME SURFACE
Split(original_surface,["red.png","green.png","blue.png","alpha.png"])

#SAVE RGBA FILES FROM FILE
Split("file_name.extension",["red.png","green.png","blue.png","alpha.png"])

Joining colour values

#RETURN RGBA PYGAME SURFACE FROM PYGAME SURFACES / FILES
rgba_surface = Join([red_surface,"green.png",green_surface,"alpha.png"],False)
 
#SAVE RGBA FILE SURFACE FROM PYGAME SURFACES / FILES
Join([red_surface,"green.png",green_surface,"alpha.png"],"file_name.extension")

Documentation

Name

image_rgba.py

Language

Python: 2.X - 3.X Requires: PyGame

Information

function image_rgba.Split(surface_or_filename, rgba_filenames=[“red.png”,“green.png”,“blue.png”,“alpha.png”])

  • This function will separate the RGBA values of a image or PyGame surface, into separate image files or if specify it will return the in form of a list of surfaces.
  • The first argument surface_or_filename will be the input file or surface to be use, either of them can be used as input for this argument.
  • The second argument rgba_filenames can be set to two different things. To False so it returns all the different images as surface in a list (in the following list order: red, green, blue, alpha), or a list can be provided with the desired names of all the four output images (in the following naming order: red, green, blue, alpha).

function image_rgba.Join(rgba_surfaces_or_filenames,filename=“rgba_joined.png”)

  • This function will regroup into a single image or PyGame surface a collection of photos representing the individual RGBA values of a photo. The can be introduced either from another surface or a file name to the image, it also can output in either format.
  • The first argument rgba_surfaces_or_filenames is a list containing either file names or surfaces, this can be alternating. For example: two surfaces and two file names; three surfaces and one file name or all surfaces or file names. This have to be in the following order: red, green, blue, alpha.
  • The final argument filename can be set two ways, either to False to output the finished surface or a string with the desired name, path and format to be saved. The recommended formats can either be .png or .jpg (PNG lossless or JPG lossy).