trimailov / qwer

Floyd-Steinberg dithering in python
14 stars 8 forks source link

Integrate script before printing with Cups #1

Open ricochebonjour opened 6 years ago

ricochebonjour commented 6 years ago

Hi man, I really like your Floyd-Steinberg effect ! I'm would like to integrate it before an automatic print on a thermal Epson TM-T20II who works with Cups.

Got this code for print;

def printCups(photo_number, filename_prefix):
    filename = filename_prefix + '_' + str(photo_number) + 'of'+ str(total_pics)+'.jpg'
    conn = cups.Connection()
    printers = conn.getPrinters()
    printer_name = list(printers)[0]
    cups.setUser('pi')
    #Photo printed one time
    conn.enablePrinter(printer_name)
conn.printFile(printer_name, photo_number, filename_prefix,{"copies": "1"})

I guess I have to manage something to print from the 'image_file' mentionned in your code ? Thank's in advance for your help.

trimailov commented 6 years ago

Thanks for using my code, though it's been 3 years since last edit - so use with caution.

If I understand your problem correctly - just use the output file, from dither function for your printer interface.

Sorry - I have no knowledge of CUPS API. But you have all of the building blocks. You have an image from my code and you have the CUPS printing interface. Just get the right information on how to pass image to the CUPS and that's it. Your example seems a bit strange and very specific.

ricochebonjour commented 6 years ago

I try to integrate it in a photobooth project with a Raspberry Pi : https://github.com/ricochebonjour/raspberry_pi_photo_booth/blob/master/camera.py

Got an image generated by a Pi Camera 'camera.capture(filename)' and code for printing comes just after. Do you think I can only use "def floyd_steinberg_dither(self, image_file)" on 'filename' ?