Class: FilePipeline::FileOperations::ExifRestoration
- Inherits:
-
FileOperation
- Object
- FileOperation
- FilePipeline::FileOperations::ExifRestoration
- Includes:
- ExifManipulable
- Defined in:
- lib/file_pipeline/file_operations/default_operations/exif_restoration.rb
Overview
A FileOperation that compares Exif Metadata in two files and copies tags missing in one from the other. Used to restore Exif tags that were not preserved during e.g. a file conversion.
Caveat: if this operation is applied to a file together with ExifRedaction, it should be applied before the latter, to avoid redacted tags being restored.
Instance Attribute Summary
Attributes inherited from FileOperation
Instance Method Summary collapse
-
#captured_data_tag ⇒ Object
Returns the DROPPED_EXIF_DATA tag defined in CapturedDataTags.
-
#initialize(**opts) ⇒ ExifRestoration
constructor
:args: options.
-
#operation(src_file, out_file, original) ⇒ Object
:args: src_file, out_file.
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) ⇒ ExifRestoration
:args: options
Returns a new instance.
Options
-
skip_tags- Exif tags to be ignored during restoration.
The ExifManipulable mixin defines a set of Exif tags that will always be ignored. These are tags relating to the file properties (e.g. filesize, MIME-type) that will have been altered by any prior operation, such as file format conversions.
27 28 29 30 31 |
# File 'lib/file_pipeline/file_operations/default_operations/exif_restoration.rb', line 27 def initialize(**opts) defaults = { skip_tags: [] } super(opts, defaults) [:skip_tags] += ExifManipulable. end |
Instance Method Details
#captured_data_tag ⇒ Object
Returns the DROPPED_EXIF_DATA tag defined in CapturedDataTags.
This operation will capture any Exif tags and their values that could not be written to the file created by the operation.
37 38 39 |
# File 'lib/file_pipeline/file_operations/default_operations/exif_restoration.rb', line 37 def captured_data_tag CapturedDataTags::DROPPED_EXIF_DATA end |
#operation(src_file, out_file, original) ⇒ Object
:args: src_file, out_file
Writes a new version of src_file to out_file with all writable Exif tags from original restored.
Will return any Exif tags that could not be written and their values from the original file as data.
48 49 50 51 52 53 |
# File 'lib/file_pipeline/file_operations/default_operations/exif_restoration.rb', line 48 def operation(src_file, out_file, original) original_exif, src_file_exif = read_exif original, src_file values = missing_exif_fields(src_file_exif, original_exif) FileUtils.cp src_file, out_file write_exif out_file, values end |