aboutsummaryrefslogtreecommitdiff

Musicture

Characteristics

  • Add music to images without noticeable quality loss.
  • Play music files from photographies.
  • Easy and simple to use user-interface.

Support

  • Graphical-User-Interface (GUI)
  • Drag N’ Drop Options
  • Command-Line Options
  • Image Formats:
    • PNG (Recommended), JPG (Recommended), BMP, PCX, TIF, LBM, PBM, PGM, PPM, XPM, GIF (Not Animated), TGA (Uncompressed)
  • Music Formats:
    • MID (Recommended), OGG, MP3
  • Tested O.S: Windows 8.1, 10

Image

History

The name comes from ‘Musical Picture’ joined together (the original name, that not very long after starting the project, a friend suggested the mixture of them into one) because of the images and music the program needs to run, being the main objective of it, to create music out of photograph.

First the project started creating music notes out of the RGB values of an image. Making different tones, times and rhythms from them. This was inspired from a video that I stumbled across a moth ago from Computerphile as it sounded pretty good. After some testing on my own, I got to the conclusion that images look fine, until you try to make music out of them (they sound horrible).

So the second phase started; not making music, using good music. This again was inspired by a Computerphile video, a steganography one, as it was of hiding data in images it came convenient. At the same time another friend (musically trained) showed me the MIDI standard hearing about the project. And as before, conveniently enough the libraries that I was using could play it and the file size of them were very small. So perfect, working prototype in an afternoon, but the quality wasn’t perfect (click on them to maximize them). Instead of 16.5 Million colour range I reduced it to 15.6 Thousand using the less significant digits of each colour value, to hide the data of the music file, still was huge but significant loss overall.

So I decide to redo it using only one of the RGB colour values, what colour? Easy, the one which is less present in the photo.

After all of this was ready, I wanted to make my whole music library like that, small images that could have tones of music (more or less). So I started with a more user-friendly version, that is what is now Musicture, a simple to use program to add music to your images (note that images labeled edited are authentic, you can save them and hear the theme song along the picture).

Utilization

Graphical-User-Interface

Playing Music

  1. Firstly select an image to play its music or to add music to it by clicking ‘OPEN’.
  2. If you want to hear the music in it press ‘PLAY’.
  3. Then the program will read the photo and it will start automatically being played.

Introducing Music

  1. Firstly select an image to play its music or to add music to it by clicking ‘OPEN’.
  2. If you prefer to introduce music to it press ‘ADD’.
  3. Secondly select a music file to be added by clicking ‘OPEN’.
  4. Then click ‘SAVE & PLAY’ and the program will determinant which method will it use to add the music.
  5. Optionally read the description of the method and press either ‘Cancel’ or ‘Accept’ if you agree with the selected quality.
  6. Then automatically the image will be replaced with the new one and it will start being played.

Drag N’ Drop

Playing Music

  1. First select your desired musical image to be played.
  2. Drag the image file on top of Muiscture’s icon and drop it.
  3. Then the program will read the photo and it will start automatically being played.

Introducing Music

  1. Select your image and music file you desire to be joined.
  2. Having them selected drag both files on top of Muiscture’s icon and drop them, then program will determinant which method will it use to add the music.
  3. Optionally read the description of the method and press ‘Accept’ or ‘Cancel’ if you agree with the selected quality.
  4. Then automatically the image will be replaced with the new one and it will start being played.

Command-Line

Playing Music

"PATH_TO_MUSICTURE\Musicture.exe" "PATH_TO_FILE\IMAGE_NAME.png"

Relative paths can be used, but it will use the Command-Line location as base. To change it use the command cd followed by the path to the base folder you prefer, before executing Musictures command.

Introducing Music

"PATH_TO_MUSICTURE\Musicture.exe" "PATH_TO_IMAGE\IMAGE_NAME.png" "PATH_To_MUSIC\MUSIC_NAME.mid"

Relative paths can be used, but it will use the Command-Line location as base. To change it use the command cd followed by the path to the base folder you prefer, before executing Musicture’s command. Also remember to change the extension of the image and music file to the one desired.

Documentation

Name

musicture_core.py

Language

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

Information

class musicture_core.HiFi()

  • The HiFi or High-Fidelity sub-module is in charge of inserting and reading music files from images, this sub-module is ranked as the 1º best option for maintaining the quality of the photograph. Music to Image ratio - 1 : 9.
  • Information from the sub-module:
    • “This method selects the less significant colour in the photograph from RBG, and from there the less significant bit of information to hide the file. In most cases the introduction of the file is undetectable without apparent quality loss.”
  • function Information()
    • Returns a string with a description of the sub-module.
      • “This methord selects the less significant colour in the photograph from RBG, and from there the less significant bit of information to hide the file. In most cases the introduction of the file is undetectable without apparent quality loss.”
  • function Capacity(image_file)
    • Gives the max music file size in bytes that can be appended to the image given with this module. The image file can be pass as a string for its full path or as a PyGame surface.
  • function Required(music_file)
    • This function is unused by Musicture but it’s included for completeness of the package. Returns the minimum size (width and height) and area needed for the introduction of the music file inside of the image, in form of a dictionary. The music file can be pass as a string for its full path.
  • function AddMusic(image_file, music_file, while_work=None)
    • This function add the music file to the image, it replaces the original with the one created if it is a PNG or creates a PNG if it is not (as JPEG is lossy compressed corrupting the music file). The image file can be pass as a string for its full path or as a PyGame surface and the music file only with its full path. The optional parameter while_work executes a callable function regularly during the process, this is use in Musicture to prevent the window from not responding while it is processing the photo.
  • function GetMusic(image_file, while_work=None)
    • This is the reversed function of AddMusic(), this will extract any music file inserted into a image by this sub-module, a path to the extracted file will be returned. The image file can be pass as a string for its full path or as a PyGame surface. The optional parameter while_work executes a callable function regularly during the process, this is use in Musicture to prevent the window from not responding while it is processing the photo.

class musicture_core.FullPx()

  • The FullPx or High-Capacity sub-module is in charge of inserting and reading music files from images, this sub-module is ranked as the 2º best option for maintaining the quality of the photograph. Music to Image ratio - 1 : 3.
  • Information from the sub-module:
    • “This method is particularly use to add a file to a photograph without taking into account the colour accuracy, the picture is easily distinguishable but was well the colour change. With a ratio of 1 to 3, file to image size, it is usually enough.”
  • function Information()
    • Returns a string with a description of the sub-module.
      • “This method is particularly use to add a file to a photograph without taking into account the colour accuracy, the picture is easily distinguishable but was well the colour change. With a ratio of 1 to 3, file to image size, it is usually enough.”
  • function Capacity(image_file)
    • Gives the max music file size in bytes that can be appended to the image given with this module. The image file can be pass as a string for its full path or as a PyGame surface.
  • function Required(music_file)
    • This function is unused by Musicture but it’s included for completeness of the package. Returns the minimum size (width and height) and area needed for the introduction of the music file inside of the image, in form of a dictionary. The music file can be pass as a string for its full path.
  • function AddMusic(image_file, music_file, while_work=None)
    • This function add the music file to the image, it replaces the original with the one created if it is a PNG or creates a PNG if it is not (as JPEG is lossy compressed corrupting the music file). The image file can be pass as a string for its full path or as a PyGame surface and the music file only with its full path. The optional parameter while_work executes a callable function regularly during the process, this is use in Musicture to prevent the window from not responding while it is processing the photo.
  • function GetMusic(image_file, while_work=None)
    • This is the reversed function of AddMusic(), this will extract any music file inserted into a image by this sub-module, a path to the extracted file will be returned. The image file can be pass as a string for its full path or as a PyGame surface. The optional parameter while_work executes a callable function regularly during the process, this is use in Musicture to prevent the window from not responding while it is processing the photo.

variable musicture_core.methords

  • This variable contains a list of the sub-modules included ranked by quality acquired after image introduction (zero being the best). The sub-modules are included as instances in the list so no creating of the is needed afterwards. If you want to obtain the name of each sub-module by the instances you can use this code example:
name_of_modules = []
for module in methords:
    name_of_modules.append(module.__class__.__name__)
 
#Example Output: ["HiFi","FullPx"]

variable musicture_core.available

  • Contains an integer showing the number of methods available in the methords variable.