Files
img2mp3/examples/README.md
ale 4c62e5032f examples
Signed-off-by: ale <ale@manalejandro.com>
2025-09-06 19:31:34 +02:00

1.6 KiB

Examples

This directory contains example files and usage demonstrations for IMG2MP3.

Files

  • basic_usage.js - Complete example showing all functionality
  • risitas.jpg - Sample image file for testing
  • chiquito-cobarde.mp3 - Sample audio file for testing

Running the Example

To run the complete example with the provided files:

# From the project root directory
npm run example

# Or run directly
node examples/basic_usage.js

What the Example Does

  1. Encodes the MP3 file into the image, creating a .i2m file
  2. Gets information about the created .i2m file
  3. Plays the embedded audio (if an audio player is available)
  4. Decodes the .i2m file back to separate image and MP3 files

Expected Output

The example will create the following files in the examples directory:

  • risitas_with_chiquito.i2m - The image with embedded audio
  • extracted_risitas.png - The extracted original image
  • extracted_chiquito.mp3 - The extracted audio file

Testing Different Files

You can replace risitas.jpg and chiquito-cobarde.mp3 with your own files to test with different content. Just make sure to update the filenames in basic_usage.js accordingly.

Audio Players

For the playback functionality to work, you need one of these audio players installed:

  • Linux: sudo apt install mpg123 or sudo apt install mpv
  • macOS: brew install mpg123 or brew install mpv
  • Windows: Install mpv

If no audio player is available, the example will show a warning but continue with the other functionality.