从目录中的所有文件中删除exif

时间:2018-07-07 01:12:09

标签: python python-2.7 metadata exif

我想从目录中的所有.JPG文件中删除exif /元数据。这是我到目前为止的内容,但是我的一部分认为这不起作用,所以...帮助吗?

function delVtlEm() {
  var i,row;

  var sheet = SpreadsheetApp.getActiveSheet(); 
  var rows = sheet.getDataRange();

  var numRows = rows.getNumRows(); 
  var values = rows.getValues(); 
  var rowsDeleted = 0; 

  var arrayOfStringsToFind = ["whatToLookFor","whatToLookFor2","whatToLookFor3"];

  for (i = 0; i <= numRows - 1; i++) {
    row = values[i];

    column1Value = row[0];//Get the value of column A for this row
    column2Value = row[1];
    column3Value = row[2];

    if (arrayOfStringsToFind.indexOf('column1Value') !== -1) { 
      values.splice(i,1);//
    }

    if (column2Value.indexOf('@vtldesign.com') !== -1) { 
      values.splice(i,1);//Remove one element in the data array at index i
    }
    if (column3Value.indexOf('whatToLoookFor') !== -1) { 
      values.splice(i,1);//
    }
  }

  sheet.clearContents();//clear the contents fo the sheet
  sheet.getRange(1, 1, values.length, values[0].length);//Set new values

}

1 个答案:

答案 0 :(得分:0)

您真的要...Metadata(file + ".jpg")是因为file上已经有.jpg

我对GExiv2一无所知。 FWIW,piexif库似乎得到了维护:

import os
import piexif

rootdir = "c:\directory\subdirectory\subdirectory2"

def noMeta(file):
  print("gutting exif data from {}".format(file))
  piexif.remove(file)

for root, dir, files in os.walk(rootdir):
  for file in files:
    if file.lower().endswith(".jpg"):
      noMeta(os.path.join(root, file))