473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Unable to Save Screenshots with dynamic name using image.grab() in PIL library

import sys
import time
import os
from PIL import ImageGrab

print("Enter time interval to take screenshot")
time_int = 3
print("Time interval entered is %(time)d" %{"time":time_int})
img = ImageGrab.grab()
localtime = time.asctime( time.localtime(time.time()) )
localtime = localtime.replace(" ","_")
environ = os.environ
Files_Dir = r'images'
save_path = r'C:\\results'
File_name = localtime+'.jpg'
print("Filename is %(File_name)s" %{"File_name":File_name})
File_path = os.path.join(save_path, Files_Dir, File_name)
directory = os.path.join(save_path, Files_Dir)
print("path where the image saved is %(path)s" %{"path":File_path})
if not os.path.exists(directory):
try:
os.makedirs(directory)
except OSError as exception:
if exception.errno!=errno.EEXIST:
raise
img.save(File_path, "JPEG")




OSError: [Errno 22] Invalid argument: 'C:\\results\\images\\Thu_Aug__4_15:40:33_
2016.jpg'
Aug 4 '16 #1
0 1137

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Stefan | last post by:
Hi, I just downloaded PHP-4.3.3 for win32 and got the extensions folder and dropped it intot he root of the PHP directory and set it's path in the PHP.ini: extension_dir =...
3
by: Willis Lang | last post by:
Warning: Unknown(): Unable to load dynamic library './php_oci8.dll' - Access is denied. Error keeps coming up on server. I made sure the security settings were set on the file and all...
19
by: Nancy | last post by:
Hi, When I start my PC(winXP Pro), it always says: Unknown(): Unable toload dynamic library './php_msql.dll' - The specified module could not be found. Then my Apache servre starts, load php...
0
by: Karim | last post by:
I am getting the error "unable to load dynamic libray php_mcrypt.dll...". I understand that php_mcrypt.dll depends on the existence of libmcrypt.dll library. I am using Windows 2003 and I have...
7
by: ccp999 | last post by:
I keep getting this: "PHP Warning: PHP Startup: Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified module could not be found." when I tried to load the php_mysql.dll...
3
by: Nikola Skoric | last post by:
Hi there, When I try to connect to mysql, I get: Fatal error: Call to undefined function mysql_connect() in D:\www\kviz \scripts\data_connect.php on line 3 PHP Warning: PHP Startup: Unable to...
0
by: danish | last post by:
I download the oci-1.2.2.tgz file and generated the oci8.so file. After adding the extension=oci8.so in php.ini I get the error unable to load dynamic library /usr/lib/php4/oci8.so
3
by: Harmony504 | last post by:
HELP! Setup: PHP5.2.5, IIS 5.1, XP, AS/400 (DB/400 or DB2) I am trying to connect to a DB2 database from my computer. I installed DB2 Connect and set up the ODBC Driver in the Data Source...
9
by: Christopher Koeber | last post by:
Hello, I am attempting to perform a PHP installation on an Apache 2.2.6 web server instance that is loaded on a Windows 2003 server operating system (R2 SP2). I have a third party application...
11
by: tregan3 | last post by:
I'm having trouble opening a color .tiff. Calling Image.FromStream on the .tiff throws an "invalid parameter" error. Calling Bitmap.FromFile on the .tiff throws a "System.OutOfMemory" error...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.