Coder Social home page Coder Social logo

instax_api's Issues

It Works! (Kind of)

Ok, so the code still needs a lot of work and is quite messy right now... However I did just print out a photo from my mac!

firsteverphoto (Incase you were wondering, the model is my pair programming buddy)

So, how do you print photos today?

  1. Download this repository and follow the instructions in the readme to setup the virtualenv environment.
  2. Edit newEx.py to change line 15 to point at the photo you would like to print.
  3. Turn on your Instax SP2 printer
  4. Connect to it's Wifi SSID (Usually INSTAX-*) where the * is the first part of the MAC address of the device.
  5. Run python3 newEx.py.

Currently, I'm dumping a load of debug to the console, and the final bit of the process that checks the status of the print isn't working (It will throw an exception). But with that in mind, it should still print! YMMV, but if anything interesting happens, feel free to raise an issue.

For now, I'm going to tidy up the project and get rid of anything that's now unnecessary, as well as try and fix the print status code. Then I'll write a proper cli application where you can use cli arguments and switches to define the photo to print as well as showing previews etc..

Doesn't work when compiling from latest master

When compiling latest master (d06a1a4) I get this when I try to run the tool:

$ instax-print 
Traceback (most recent call last):
  File "/usr/local/bin/instax-print", line 4, in <module>
    __import__('pkg_resources').run_script('instax-api==0.5', 'instax-print')
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 657, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 1428, in run_script
    .format(**locals()),
pkg_resources.ResolutionError: Script 'scripts/instax-print' not found in metadata at '/home/bserem/.local/lib/python3.6/site-packages/instax_api-0.5.dist-info'

Checking out 14d9aea compiles and goes a bit deeper, but still doesn't print:

$ instax-print ~/Desktop/6.JPG -v 3
--- Instax Printer Python Client ---

Connecting to Printer.
Model: SP-3
Firmware: 01.02
Battery State: 3
Prints Remaining: 10
Total Lifetime Prints: 10

Printing Image: /home/bserem/Desktop/6.JPG
Traceback (most recent call last):
  File "/usr/local/bin/instax-print", line 4, in <module>
    __import__('pkg_resources').run_script('instax-api==0.4', 'instax-print')
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 657, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 1437, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.6/dist-packages/instax_api-0.4-py3.6.egg/EGG-INFO/scripts/instax-print", line 116, in <module>
    instaxImage.convertImage()
  File "/usr/local/lib/python3.6/dist-packages/instax_api-0.4-py3.6.egg/instax/instaxImage.py", line 103, in convertImage
    self.myImage = pure_pil_alpha_to_color_v2(newImage, (255,255,255))
  File "/usr/local/lib/python3.6/dist-packages/instax_api-0.4-py3.6.egg/instax/instaxImage.py", line 268, in pure_pil_alpha_to_color_v2
    background.paste(image, mask=image.split()[3])  # 3 is the alpha channel
IndexError: tuple index out of range

constraint with 10 prints

I'm trying to increase the printer's capacity and found that printer stops when 10 prints were passed.
Does anyone try the same?
Can I set "Prints Remaining: 0" programmatically?
Is there any API that doesn't in the current release?

SP-1 attempts

Hi! Excited to see this project, and I'm interested in SP-1 support.

Using sp2.py as a base, initial communication with an SP-1 is successful if I remove:

printerSpecifications = self.getPrinterSpecifications()

and

'specs': printerSpecifications.payload,

from getPrinterInformation().

With that, it gets as far as attempting to send the photo to the printer:

--- Instax Printer Python Client ---

Connecting to Printer.
Model: SP-1
Firmware: 03.22
Battery State: 4
Prints Remaining: 10
Total Lifetime Prints: 119

Printing Image: /Users/vitorio/Downloads/IMG_20180713_121051175.jpg
[========================------------------------------------] 40.0% ...About to send Image.                       
Traceback (most recent call last):
  File "/Users/vitorio/Documents/instax-print/.venv/bin/instax-print", line 116, in <module>
    myInstax.printPhoto(encodedImage, printProgress)
  File "/Users/vitorio/Documents/instax-print/.venv/lib/python3.7/site-packages/instax/sp2.py", line 239, in printPhoto
    self.sendSendImageCommand(segment, bytes(segmentBytes))
  File "/Users/vitorio/Documents/instax-print/.venv/lib/python3.7/site-packages/instax/sp2.py", line 143, in sendSendImageCommand
    response = self.sendCommand(cmdPacket)
  File "/Users/vitorio/Documents/instax-print/.venv/lib/python3.7/site-packages/instax/sp2.py", line 80, in sendCommand
    reply = self.send_and_recieve(encodedPacket, 5)
  File "/Users/vitorio/Documents/instax-print/.venv/lib/python3.7/site-packages/instax/sp2.py", line 72, in send_and_recieve
    raise(CommandTimedOutException())
instax.exceptions.CommandTimedOutException

According to the log, the "prep command" receives a response; it's the first "Send Image" command that does not.

Stuck when pass image to the printer

Hi.

I'll try to use a printer with Kivy application and tinker board.
But sometimes I have an error.

Since this situation repeats, I've decided to create this issue.

Here how it happens:

Power signal via GPIO

InstaxWorks: call to print INSTAX <-- about 1 minute since the printer was powered

[------------------------------------------------------------] 0.0% ...Connecting to instax Printer.
[======------------------------------------------------------] 10.0% ...Connected! - Sending Pre Print Commands.
[============------------------------------------------------] 20.0% ...Locking Printer for Print.
[==================------------------------------------------] 30.0% ...Reseting Printer.
[========================------------------------------------] 40.0% ...About to send Image.
[========================------------------------------------] 40.0% ...Sent image segment 0.
[=========================-----------------------------------] 41.0% ...Sent image segment 1.
[=========================-----------------------------------] 42.0% ...Sent image segment 2.
[==========================----------------------------------] 43.0% ...Sent image segment 3.
[==========================----------------------------------] 44.0% ...Sent image segment 4.
[===========================---------------------------------] 45.0% ...Sent image segment 5.
[============================--------------------------------] 46.0% ...Sent image segment 6.
[============================--------------------------------] 47.0% ...Sent image segment 7.
[=============================-------------------------------] 48.0% ...Sent image segment 8.

And stuck here for some time and then print to the stdout:

[INFO ] [Base ] Leaving application in progress...
Traceback (most recent call last):
File "fotomat.py", line 241, in
PhotoApp().run()
File "/home/linaro/.local/lib/python3.5/site-packages/kivy/app.py", line 826, in run
runTouchApp()
File "/home/linaro/.local/lib/python3.5/site-packages/kivy/base.py", line 502, in runTouchApp
EventLoop.window.mainloop()
File "/home/linaro/.local/lib/python3.5/site-packages/kivy/core/window/window_sdl2.py", line 727, in mainloop
self._mainloop()
File "/home/linaro/.local/lib/python3.5/site-packages/kivy/core/window/window_sdl2.py", line 460, in _mainloop
EventLoop.idle()
File "/home/linaro/.local/lib/python3.5/site-packages/kivy/base.py", line 337, in idle
Clock.tick()
File "/home/linaro/.local/lib/python3.5/site-packages/kivy/clock.py", line 581, in tick
self._process_events()
File "kivy/_clock.pyx", line 384, in kivy._clock.CyClockBase._process_events
File "kivy/_clock.pyx", line 414, in kivy._clock.CyClockBase._process_events
File "kivy/_clock.pyx", line 412, in kivy._clock.CyClockBase._process_events
File "kivy/_clock.pyx", line 167, in kivy._clock.ClockEvent.tick
File "fotomat.py", line 228, in <--- here Clock lambda with timeout about 5 minutes
Clock.schedule_once(lambda *args: self.instaxClass.print_image(self.run_print_finish), 1)
File "fotomat.py", line 120, in print_image
instax_instance.printPhoto(encoded_image)
File "/home/linaro/.local/lib/python3.5/site-packages/instax/sp2.py", line 252, in printPhoto
self.sendSendImageCommand(segment, bytes(segmentBytes))
File "/home/linaro/.local/lib/python3.5/site-packages/instax/sp2.py", line 156, in sendSendImageCommand
response = self.sendCommand(cmdPacket)
File "/home/linaro/.local/lib/python3.5/site-packages/instax/sp2.py", line 92, in sendCommand
reply = self.send_and_recieve(encodedPacket, 120) <-- here I try to increase timeout from 5 to 120, but it doesn't help
File "/home/linaro/.local/lib/python3.5/site-packages/instax/sp2.py", line 79, in send_and_recieve
raise(ConnectError(reply.data))
instax.exceptions.ConnectError: timed out

This error is not fired every time, but very frequently - about three times from five. I can't recognize any system in error occurring cases.

A printer is still online. I can ping them.
Wifi settings in the system use wpa_supplicant.config
network={
ssid="INSTAX-"
key_mgmt=NONE
}
with current printer wifi ssid

Question: Instax or Local WIFI ?

The library must be installed on a device connected directly to the Instax Wifi ?
It's not possible to connect the Instax to the Home Wifi then send print action throught that wifi ?

Polaroid Now+

Hello,

I'm a total Noob when it comes to making software that connects to devices. But I wonder if anyone here can answer this for me: is it possible to write a similar API for Polaroid Now+ cameras? They have a Bluetooth interface that connects with their app which can control the camera's exposure and other settings (but the camera itself is 100% analogue, i.e., it exposes film to light directly).

Thanks so much and sorry if I'm breaking the flow here.

Packet capture data

I recently captured some interaction with my Instax using a Remote Virtual Interface.
Namely, I printed out two different photos of different resolutions (as per their source images), but noted that the resultant image sent was fixed size.

Is it worth posting the PCAP files here for inspection?

Any iOS or Android Version?

I am not familiar with python, and tried to translate python to swift to get it work in iPhone. But failed. Any suggestion to make it work on mobile?

And I find there is an option in its original app to keep the printer from shutdown. Can you add this function in the project?

Raspberry Pi 3 Model B - Segmentation Fault

First off, thanks so much for your work on this project.
So far, everything has worked pretty flawlessly on my Mac.
However, when I try to run "instax-print" on Raspbian (Jessie) I'm getting:
Connecting to Printer.
[Model, etc...]

Printing Image: myimage.jpg
Segmentation fault

Any help is much appreciated. Thanks for your time.

  • Teddy

Fujifilm Instax SP-3 support?

I think about buying a Fujifilm Instax SP-3 printer, but is this library compatible if you just change the image resolution? Or does the SP-3 have a completely other protocol?

Can somebody who owns a Fujifilm Instax SP-3 test it? If you just need to change the resolution, it should be easy to support both printers.

Test Suite

Tests To Write:

  • Specifications Command (79)
  • Specifications Response (79)
  • Reset Command (80)
  • Reset Response (80)
  • Prep Printer Command (81)
  • Prep Printer Response (81)
  • Send Image Command (82)
  • Send Image Response (82)
  • Set Lock State Command (176)
  • Set Lock State Response (176)
  • Lock Device Command (179)
  • Lock Device Response (179)
  • Change Device Command (182)
  • Change Device Response (182)
  • Printer Version Command (192)
  • Printer Version Response (192)
  • Print Count Command (193)
  • Print Count Response (193)
  • Model Name Command (194)
  • Model Name Response (194)
  • Unknown 2 Command (195)
  • Unknown 2 Response (195)
  • Pre Print Command (196)
  • Pre Print Response (196)

Multiple (Sleep / Connect / Close) purpose.

Hey,

I have been working on a project to use my SP-3 for a photobooth.
Basically I am running a CUPs server on a separate device (MQ-Quad) which calls a python script calling the functions needed for printing from this api.

Everything is working as intended just trying to speed up the process of printing.
I have noticed a ton of "time.sleep(1)" & myInstax.connect() / myInstax.close().
I'm wondering if a single connect at the start and close at the end of the script will suffice and if the 1 second sleeps in-between are necessary.

Cropping landscape image calculation seems to be wrong

I noticed I was getting errors on cropping images that were landscape—as far as I can tell, the middle crop_rectangle command in instaxImage.py is calculated incorrectly. Here's my hacky version that works:

elif crop_type == 'middle':
       box = (int(round((img.size[0] - size[0]) / 2)), 0,
               int(round(((img.size[0] - size[0])/2)+size[0])), img.size[1])
        print(box)

Turning off Auto-Shutdown

Is there a way to turn off the "auto shutdown" of Instax Share sp3?

I was hoping that sending some commands (like getPrinterInformation) every minute will make it never go to sleep, but it does not work.

Anybody has a clue how to turn off the shutrdown feature?
Maybe I should send some other commands?

No Route To Host // Issue Using Instax-Print On Raspberry Pi2

I'm using the Raspberry Pi 2 Model 2 V1.1, I am connected to the instax printer by wifi and my WLAN is configured - i can see this in the Pi wifi at the top right of the screen.
I've enabled DHCP like this:

sudo nano /etc/network/interfaces

iface wlan0 inet dhcp

However, when I try to send a print across to the instax from the command line:

sudo instax-print /home/pi/image.jpg

I get the following

--- Instax Printer Python Client---

Connecting to Printer

Followed by this error:

File "/usr/local/lib/python3.4/dist-packages/instax_api-0.6-py3.4.egg/instax/sp2.py", line 44 in connect raise(ConnectionError(reply.data)) instax.exceptions.ConnectionError: [Errno 113] No route to host

Its weird it looks like the Pi's connected (it has an IP and the Instax printer is on wlan0). But as soon as I send the command to print then it looks like the Pi can't connect to the printer. How can I resolve this issue or begin to approach a solution?

Any support with resolving this would be greatly appreciated.

Preview before print?

I've been using this tool for more than a year now and I am loving it so far.

I face one very common issue though: on SP3 a lot of times my photos are being printed rotated by 90/-90 degrees. I see them just fine on my computer (with Gimp or Geeqie on Linux) so I go on and print them only to get a rotated print.

I was wonder if it would be possible to add a preview functionality before printing, even with some flag that would not result in a print (eg: instax-print -v 2 --preview FILE.JPG that would work even without a printer connected).

Could something like this be possible?
Thanks

Wiki not public

There are some references to wiki pages, but the wiki is not accessible. Could you please make the wiki public accessible? Thank you!

Problem on image Orientation

Directly indicating a non 600*800 image to instax.print module will cause the program to put the longer side on the bottom in the middle (the end close to where liquid developer comes out).

Reprint button programmable?

Just curious - any idea if pressing the "reprint" button on the Instax printer broadcasts a message that could be intercepted / used to do something different? Or is the functionality hard coded and only local to the device?
Thanks.

tuple index out of range with SP-2

I tried to print using the latest version from pip and an SP-2 printer.
The image was saved with a 600x800 pixel resolution (don't really know if this is required).
I am getting the following error:

instax-print -v 2 BSRM2001.JPG 
--- Instax Printer Python Client ---

Connecting to Printer.
Model: SP-2
Firmware: 01.21
Battery State: 3
Prints Remaining: 7
Total Lifetime Prints: 17

Printing Image: BSRM2001.JPG
Traceback (most recent call last):
  File "/usr/local/bin/instax-print", line 110, in <module>
    instaxImage.convertImage()
  File "/usr/local/lib/python3.6/dist-packages/instax/instaxImage.py", line 103, in convertImage
    self.myImage = pure_pil_alpha_to_color_v2(newImage, (255,255,255))
  File "/usr/local/lib/python3.6/dist-packages/instax/instaxImage.py", line 268, in pure_pil_alpha_to_color_v2
    background.paste(image, mask=image.split()[3])  # 3 is the alpha channel
IndexError: tuple index out of range

At the very same moment I am trying with SP-3 and an image of 3646x3646 pixel resolution.
Prints fine, results are excellent.

 $ instax-print -v 3 BSRM2231.JPG 
--- Instax Printer Python Client ---

Connecting to Printer.
Model: SP-3
Firmware: 01.02
Battery State: 3
Prints Remaining: 8
Total Lifetime Prints: 22

Printing Image: BSRM2231.JPG
[============================================================] 100.0% ...Print is complete!                          
Thank you for using instax-print!

        \   /\
        )  ( ')
        (  /  )
         \(___)|

(love the cat, or whatever that is)

Is it possible that v3 commits broke v2 or is the driver expecting something different from me?

Breaks with August 2018 commits

Commits:

7e98817 (HEAD -> master, origin/master, origin/HEAD) Initial SP-3 functionality, not quite working yet..
6678649 Improving the instax print utility in prep for more versions of SP printers

Result in this:

instax-print -h
Traceback (most recent call last):
  File "/usr/local/bin/instax-print", line 4, in <module>
    __import__('pkg_resources').run_script('instax-api==0.4', 'instax-print')
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 657, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 1428, in run_script
    .format(**locals()),
pkg_resources.ResolutionError: Script 'scripts/instax-print' not found in metadata at '/usr/local/lib/python3.6/dist-packages/instax_api-0.4.dist-info'

Last working commit is 9f1c648 (supports only sp2).
Changes in 6678649 give the error above.

UnicodeDecodeError: 'ascii' codec can't decode byte 0xfb in position 0

After a couple of successful prints on the SP2 I tried to print a 3rd image and got the following error.
All attepts failed.

Disconnecting my debian system from the printer network and reconnecting solved the issue.
I did not reboot the printer, only re-connected to it.

It might be nothing, but since it occured I am passing this information here.

bserem@dwarf ~/Desktop/Instax/SP2 $ instax-print SRM02856.JPG 
--- Instax Printer Python Client ---

Connecting to Printer.
Traceback (most recent call last):
  File "/usr/local/bin/instax-print", line 103, in <module>
    info = myInstax.getPrinterInformation()
  File "/usr/local/lib/python3.6/dist-packages/instax/sp2.py", line 191, in getPrinterInformation
    printerModel = self.getPrinterModelName()
  File "/usr/local/lib/python3.6/dist-packages/instax/sp2.py", line 94, in getPrinterModelName
    response = self.sendCommand(cmdPacket)
  File "/usr/local/lib/python3.6/dist-packages/instax/sp2.py", line 81, in sendCommand
    decodedResponse = self.packetFactory.decode(reply.data)
  File "/usr/local/lib/python3.6/dist-packages/instax/packet.py", line 63, in decode
    return(ModelNameCommand(mode=self.mode, byteArray=byteArray))
  File "/usr/local/lib/python3.6/dist-packages/instax/packet.py", line 670, in __init__
    self.payload = self.decodeRespPayload(byteArray)
  File "/usr/local/lib/python3.6/dist-packages/instax/packet.py", line 697, in decodeRespPayload
    self.modelName = self.getPrinterModelString(16, byteArray)
  File "/usr/local/lib/python3.6/dist-packages/instax/packet.py", line 435, in getPrinterModelString
    return str(byteArray[offset: offset + 4], 'ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfb in position 0: ordinal not in range(128)

Possible to connect via USB?

Hi 👋
First of all thanks for this awesome library. Finally I can print to my SP-2 without relying on mobile apps ❤️

I'm wondering if you know if it's possible to connect and print to the Instax printers by connecting it with USB instead of WiFi? Perhaps not with this library as it is now, but if it's possible at all? I would like to get a more reliable connection as I will be having it tightly coupled with a RPi. The device is discoverable at least running lsusb.

Many thanks
Best regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.