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 modifying FileOperation that compares a file’s Exif Metadata with that of a reference file and attempts to copy tags missing in the working file from the reference file.
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
Writes a new version of
src_file
toout_file
with all writable Exif tags fromoriginal
restored.
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, #modifies?, #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.
29 30 31 32 33 |
# File 'lib/file_pipeline/file_operations/default_operations/exif_restoration.rb', line 29 def initialize(**opts) defaults = { skip_tags: [] } super(opts, defaults) @options[: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.
39 40 41 |
# File 'lib/file_pipeline/file_operations/default_operations/exif_restoration.rb', line 39 def captured_data_tag CapturedDataTags::DROPPED_EXIF_DATA end |
#operation(src_file, out_file, original) ⇒ Object
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 |