Python Bulk Modified Image EXIF properties

Source: Internet
Author: User

Python Bulk Modified Image EXIF properties

Altogether two documents

Config.ini//Put config file

exif.py//Main program Files

Config.ini File Source

[Global]  Artist = www.blmm.com; the author datetimeoriginal = Now; the time is current time, as specified time is in the format: 2017:04:09 14:13:22) software = Adobe Photoshop CS6 Windows; program Name

exif.py File Source

#ecoding: Utf-8import pyexiv2 as Evimport timeimport osimport configparserclass Exif (): Def __init__ (self): confi g = Configparser.configparser () CONFIG.READFP (open (' Config.ini ', "RB")) self. Artist = Config.get ("Global", "Artist") self. Datetimeoriginal = Config.get ("Global", "datetimeoriginal") self.            Software = Config.get ("Global", "Software") def Imgsave (self,dirname): for filename in Os.listdir (dirname): Path = dirname + filename if Os.path.isdir (path): path + = '/' Self.imgsave (path) else:self.imgExif (PATH) def imgexif (Self,path): Try:if self.            Datetimeoriginal = = "Now": MyTime = Time.strftime ('%y:%m:%d%h:%m:%s ', Time.localtime (Time.time ())) Else:mytime = self. Datetimeoriginal exiv_image = ev. Imagemetadata (Path) exiv_image.read () exiv_image["Exif.Image.Artist"] = self.Artist exiv_image["Exif.Photo.DateTimeOriginal"] = mytime exiv_image["Exif.Image.Software"] = Self.s Oftware exiv_image.write () print U ' Picture: ', Path,u ' operation succeeded ' Except:print u ' Picture: ', Path,u ' Failed ' Def star (self): path = Raw_input (Unicode (' Enter picture path: ', ' utf-8 '). Encode (' GBK ') #newpath = Unicode (path , ' UTF8 ') self.imgsave (path+ '/') Self.star () print u ' #------------------------------------' Print U ' # program: Batch modification diagram Piece Exif info ' Print u ' # path format: g:\ picture ' Print U ' #------------------------------------' exif = EXIF () Exif.star ()

Operating effect:

Drag folder to window enter

Note: The Pyexiv2 module is used to modify EXIF information.

Https://launchpad.net/pyexiv2

Python Bulk Modified Image EXIF properties

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.