1.6 KiB
1.6 KiB
Examples
This directory contains example files and usage demonstrations for IMG2MP3.
Files
basic_usage.js- Complete example showing all functionalityrisitas.jpg- Sample image file for testingchiquito-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
- Encodes the MP3 file into the image, creating a
.i2mfile - Gets information about the created
.i2mfile - Plays the embedded audio (if an audio player is available)
- Decodes the
.i2mfile 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 audioextracted_risitas.png- The extracted original imageextracted_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 mpg123orsudo apt install mpv - macOS:
brew install mpg123orbrew install mpv - Windows: Install mpv
If no audio player is available, the example will show a warning but continue with the other functionality.