This module can be used to control your Instax bluetooth printer from Python. Create an issue if you run into any trouble, but please read the rest of this readme first.
Did you find this script useful? Feel free to support my open source software:
This script has been tested with the Instax Mini Link and the Instax Square Link, but should also work with the Mini Link 2 and Wide Link. I'm unsure about some of the other models, but maybe? If you have a different model let met know if this code works for you. If it doesn't you can find some info on recording the bluetooth data between your phone and the printer here (Android) and here (IOS). The IOS logs are strongly prefered as Android uses a slightly different way of communicating.
@ Fuijfilm: feel free to send some of your other models if you want me to support those as well ;)
Model | Tested |
---|---|
Instax Mini Link | ✔️ |
Instax Mini Link 2 | ⚪ |
Instax Mini LiPlay | ⚪ |
Instax Square Link | ✔️ |
Instax Square Wide | ✔️ |
The image send to the printer should be a JPEG at a specific image size, depending on the printer model. This script will automatically convert, resize and reduce quality to match the required specifications. For best results though, ypou might want to prepare your image yourself beforehand so you keep control over the settings. The needed image sizes are:
Model | Image size |
---|---|
Instax Mini Link | 600 x 800px |
Instax Mini Link 2 | 600 x 800px (a guess) |
Instax Mini LiPlay | 600 x 800px (a guess) |
Instax Square Link | 800 x 800px |
Instax Square Wide | 1260 x 840px |
Don't need Python and just want to print? This website based on InstaxBLE lets you print to your Instax printer straight from your browser (repo over here). Working with one of the older WiFi enabled Instax printers instead? Give Instax-api a try!.
# Clone the repo
git clone https://github.com/javl/InstaxBLE.git
cd InstaxBLE
# create a virtual environment and install the needed dependencies
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Run the example
python3 instax-ble.py
By default the instax.print_image()
method will send all data to the printer except the final print command. This is to prevent accidental prints when you're still testing your code. To allow printing either call instax.enable_printing()
at any time after creating your InstaxBLE
instance or enable it at creation time by specifying print_enabled=True
in the constructor:
instax = InstaxBLE()
instax.connect()
instax.enable_printing() # allow printing
instax.print_image('image.jpg') # print image
instax.disconnect() # all done, disconnect
or
instax = InstaxBLE(print_enabled=True) # enable printing at Initialization
instax.connect()
instax.print_image('image.jpg') # print image
instax.disconnect() # all done, disconnect
By default, this script will connect to the first Instax printer it can find, but you can also specify the name (device_name
) or address (device_address
) of the printer you want to connect to:
# use the first printer that we can find:
instax = InstaxBle()
# Connect to a printer by device name. Ommit the (Android) or (IOS) part you might see in your Bluetooth settings:
instax = InstaxBle(device_name='INSTAX-12345678')
# Connect to a printer by device address (probably starts with FA:AB:BC):
instax = InstaxBle(device_address='FA:AB:BC:xx:xx:xx')
It's recommended to wrap your code inside a try / except / finally
loop so you can catch any errors (or KeyboardInterrupt
s) and disconnect from the printer gracefully before dropping out of your code. Otherwise you might have to manually restart your printer for it to connect again.
try:
instax = InstaxBle()
instax.connect()
instax.enable_printing()
instax.print_image('image.jpg')
except Exception as e:
print(e)
finally:
instax.disconnect()
The final image send to the printer should be a JPEG at a specific size (depends on the printer model, see the list above). This script will convert and resize your image if needed, but for best results you might want to prepare the image in the right format yourself. Just keep that in mind if you get unexpected results in quality. I also don't know what happens when you try to print an image in the wrong orientation.
- ✔️ Test on Linux
- ✔️ Test on MacOS
- ⬜ Test on Raspberry Pi
- ⬜ Test on Windows
Some of these options have already been explored in other branches, but I need to bring them into the main branch.
- ✔️ Get battery level
- ✔️ Get number of photo's left in cartridge
- ✔️ Get accelerometer data
- ⬜ Get button press
I'm not sure what happens when you send a different filetype or image in landscape orientation, but assuming those will fail:
- ✔️ Resize if image too small or too large (actual size depending on printer model)
- ✔️ Resize if file size too large (max 65535 bytes)
- ⬜ Auto rotate image to portrait before sending
- ⬜ Convert to jpg if given a different filetype
- ⬜ Strip exif data to decrease filesize
- ✔️ Automatically lower the quality of the image to keep images below the 65535 bytes (0xFF 0xFF) file limit
- Huge thank you to everyone in this instax-api thread (and @hermanneduard specifically) for their help in reverse engineering the Bluetooth protocol used.
- Thanks to @kdewald for his help and patience in getting simplepyble to work.
- Test pattern image: Test Pattern Vectors by Vecteezy
This project is licensed under the MIT License.