Class: FilePipeline::FileOperations::ExifRedaction

Inherits:
FileOperation
  • Object
show all
Includes:
ExifManipulable
Defined in:
lib/file_pipeline/file_operations/default_operations/exif_redaction.rb

Overview

A FileOperation that will redact (delete) unwanted Exif tags from a file’s metadata.

This could be tags containing sensitive data, such as e.g. GPS location data.

Caveat: if this operation is applied to a file together with ExifRestoration, it should be applied after the latter, to avoid redacted tags being restored.

Instance Attribute Summary

Attributes inherited from FileOperation

#options

Instance Method Summary collapse

Methods included from ExifManipulable

#delete_tags, file_tags, #missing_exif_fields, #parse_exif_errors, parse_tag_error, #read_exif, strip_path, #write_exif

Methods inherited from FileOperation

#extension, #failure, #name, #results, #run, #success, #target, #target_extension

Constructor Details

#initialize(**opts) ⇒ ExifRedaction

:args: options

Returns a new instance.

Options
  • redact_tags - Exif tags to be deleted.



25
26
27
28
# File 'lib/file_pipeline/file_operations/default_operations/exif_redaction.rb', line 25

def initialize(**opts)
  defaults = { redact_tags: [] }
  super(opts, defaults)
end

Instance Method Details

#captured_data_tagObject

Returns the DROPPED_EXIF_DATA tag defined in CapturedDataTags.

This operation will capture all Exif tags and their values are declared in #options redact_tags that are redacted from the file created by the operation.



35
36
37
# File 'lib/file_pipeline/file_operations/default_operations/exif_redaction.rb', line 35

def captured_data_tag
  CapturedDataTags::DROPPED_EXIF_DATA
end

#operation(*args) ⇒ Object

:args: src_file, out_file

Writes a new version of src_file to out_file with all Exif tags provided in the redact_tags option deleted.

Will return all deleted Exif tags and their values as data.



45
46
47
48
49
# File 'lib/file_pipeline/file_operations/default_operations/exif_redaction.rb', line 45

def operation(*args)
  src_file, out_file = args
  FileUtils.cp src_file, out_file
  delete_tags out_file, options[:redact_tags]
end