Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
automatically printing
#1
When I am photographying at an event, I need to print as I take the image.
When I photograph, I connect a cable from the camera to my macbook Pro(tethered).
The image, when taken goes to Adobe lightroom, is edited and saved.
I then need (I have been informed that Python is the tool) to read the folder and then send any JPG images in that folder to the connected printer.
So in approx 15 seconds, I have taken an image, it is edited, saved in a folder and then printed.
Reply
#2
I do something like this, but on command, not automatically, to convert .xlsx files to pdf and then send them to the printer.

Apple computers use a Unix based system, I believe, so this script will send jpgs to the printer you designate.

A Linux programme incron uses inotify to monitor changes to a specific directory. Any time you put a photo in there, it can trigger the bash script below. Read this.

Not Python though!!

Output:
#! /bin/bash # set your paths JPGfiles="/home/pedro/temp/*.jpg" backupPath='/home/pedro/backupJPGs/" for X in $JPGfiles do if test $X then echo "This is one of the files:" printf $X; echo "Now sending the file to the printer ... " # set your printer lp -d "EPSON-L380-Series" $X; # get rid of the jpg after sending to the printer # or move it to backupPath # mv $X $backupPath echo "Junking the jpeg ... " rm $X; fi done
Larz60+ write Jan-22-2022, 10:41 AM:
Using output tags, even though wrong title will format bash scripts properly.
Reply
#3
At least for Ubuntu, incron will save the incrontab file in /var/spool/incron/

First you need to add yourself to the allowed users in:

/etc/incron.allow

Just your user name on one line.

Then you can edit your incrontab with

incrontab -e (this calls nano editor on my system)

I put this:

Quote:/home/pedro/temp IN_MODIFY /home/pedro/myBashscripts/lp_JPGv2.sh

Now, if I copy a .jpg file to /home/pedro/temp it will immediately be sent to the printer of my choice, set in the bash script.
Reply
#4
Just got a tip on a shorter method to do this: use wildcards:

Quote:$@ watched filesystem path (see above)
$# event-related file name

Make the incrontab like this:

Quote:/home/pedro/temp IN_MODIFY lp -d "EPSON-L380-Series" $@/$# && rm $@/$#;

Then, any photo arriving in the directory will immediately be sent to the printer and deleted. (Could save it somewhere if desired.)

Are my eyes failing, or has everything gone black??
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020