class FilePipeline::FileOperations::ExifRestoration
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.
Public Class Methods
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.
# 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.file_tags end
Public Instance Methods
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.
# File lib/file_pipeline/file_operations/default_operations/exif_restoration.rb, line 39 def captured_data_tag CapturedDataTags::DROPPED_EXIF_DATA end
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.
# 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