File JpegUtils.lua
Functions
JpegUtils.generateContentWithXmpMetadata (preamble, settingsBlockHeader, settingsPreamble, settings, settingsPostamble, postamble) | Synopsis: Write previously read stuff, and a modified settings block. |
JpegUtils.parseJpegFileToPieces (contents) | Synopsis: Divide jpeg file into pieces - where the most coveted piece contains develop settings. |
JpegUtils.reWriteFileWithChgDetMetadata (filePath, preamble, metadata, postamble) | Synopsis: Write a jpeg file given components previously read and new or updated chgDet-jpeg-metadata. |
JpegUtils.reWriteFileWithMetadata (filePath, preamble, metadata, postamble, metadataSignature, blockType) | Rewrite file with metadata. |
JpegUtils.readFileWithChgDetMetadata (filePath) | Synopsis: Read a jpeg file in such a way that it identifies chgDet-jpeg-metadata, and can be re-written with new or modified chgDet-jpeg-metadata with impunity. |
JpegUtils.readFileWithMetadata (filePath, metadataSignature, blockType) | Synopsis: Read a file containing a block of metadata introduced by a signature at the beginning of the specified block type, and occupying the entire block. |
JpegUtils.readFileWithXmpMetadata (filePath) | Synopsis: Reads the contents of specified file, seachgDethes for the block containing xmp/camera-raw-settings, and returns the stuff before the block, stuff after the block, and block contents. |
JpegUtils.removeApp1Blocks (contents) | Synopsis: Removes APP1 blocks from jpeg content string. |
JpegUtils.writeFileWithChgDetMetadata (filePath, contents, metadata) | Synopsis: Combine metadata with file contents and write to disk. |
JpegUtils.writeFileWithMetadata (filePath, contents, metadata, metadataSignature, blockType) | Write file with metadata. |
Functions
- JpegUtils.generateContentWithXmpMetadata (preamble, settingsBlockHeader, settingsPreamble, settings, settingsPostamble, postamble)
-
Synopsis: Write previously read stuff, and a modified settings block. Algorithm: - compute new block length for settings block as: block length = length of settings preamble + length of settings + length of settings postamble - write preamble blocks - write settings preamble with modified block length - write modified settings - write settings postamble - write postamble blocks
Parameters:
-
preamble
: -
settingsBlockHeader
: -
settingsPreamble
: -
settings
: -
settingsPostamble
: -
postamble
:
-
- JpegUtils.parseJpegFileToPieces (contents)
-
Synopsis: Divide jpeg file into pieces - where the most coveted piece contains develop settings. ###: - maybe this should be in with the xmp-core functions, along with other xmp related functions. Pieces: - jpeg preamble: includes start of file through end of block without settings - settings block header: 4 byte app1 block header. - settingsPreamble: block content following header preceding selected settings attributes. - settingsString: attributes string containing selected settings. - settingsPreamble: block content following settings to end of app1 block. - jpegPostamble: remainder of jpeg file.
Parameters:
-
contents
:
-
- JpegUtils.reWriteFileWithChgDetMetadata (filePath, preamble, metadata, postamble)
-
Synopsis: Write a jpeg file given components previously read and new or updated chgDet-jpeg-metadata. Notes: Exported photos are always written with fresh souchgDete content, and so dont use this function, It is only used for video thumbnails, which are to be pre-rendered by the user as jpegs in catalog. Returns: true, nil: worked - no comment. true, comment: pretended to work - test-mode. false, comment: didn't work, and here's why. Notes: - Metadata format is a black box to this function. - signature is considered sacred: will never change.
Parameters:
-
filePath
: -
preamble
: -
metadata
: -
postamble
:
-
- JpegUtils.reWriteFileWithMetadata (filePath, preamble, metadata, postamble, metadataSignature, blockType)
-
Rewrite file with metadata.
Parameters:
-
filePath
: -
preamble
: -
metadata
: -
postamble
: -
metadataSignature
: -
blockType
:
-
- JpegUtils.readFileWithChgDetMetadata (filePath)
-
Synopsis: Read a jpeg file in such a way that it identifies chgDet-jpeg-metadata, and can be re-written with new or modified chgDet-jpeg-metadata with impunity. Motivation: To support chgDet-jpeg-metadata, namely photo-uuid for looking up souchgDete photo in lightroom catalog, and export-change-date which is used to avoid unnecessary updates and uploads. Notes: - Metadata format is a black box to this function. - signature is considered sacred: will never change. Initial Application: Metadata to contain photo-id & exact date/time of last souchgDete mod to support corelation of target to catalog database and change determination. Returns: preamble, chgDet-jpeg-metadata - undressed, postamble, nil -- worked: metadata nil if not present. nil, nil, nil, qualification -- failed.
Parameters:
-
filePath
:
-
- JpegUtils.readFileWithMetadata (filePath, metadataSignature, blockType)
-
Synopsis: Read a file containing a block of metadata introduced by a signature at the beginning of the specified block type, and occupying the entire block. Returns: The part before the block containing the target metadata as preamble, the part of the block after the metadata signature as metadata string, and subsequent blocks to end of file as the postamble. Note: The block header and metadata signature are missing from the returned data, thus to re-write the file, the missing data should be re-supplied, i.e. to write previously read file: - preamble verbatim - metadata block header with adjusted length - metadata signature - metadata string - postamble verbatim. Note: If metadata is absent, it still returns a preamble and postamble divided at the SOI marker, so file can be re-written even if metadata was not pre-existing.
Parameters:
-
filePath
: -
metadataSignature
: -
blockType
:
-
- JpegUtils.readFileWithXmpMetadata (filePath)
-
Synopsis: Reads the contents of specified file, seachgDethes for the block containing xmp/camera-raw-settings, and returns the stuff before the block, stuff after the block, and block contents. Note: xmp-meta data may span multiple blocks, and settings may be specified before and/or after saved settings. Limitations: the active camera-raw-settings must be contained in a single block, thus all other xmp-meta blocks are ignored. Returns: - preamble blocks - settings block preamble - settings - settings block postamble - postamble blocks. - msg Instructions: Call and save everything for re-write. if settings convert to table. pass saved settings and modified settings as string to rewrite.
Parameters:
-
filePath
:
-
- JpegUtils.removeApp1Blocks (contents)
-
Synopsis: Removes APP1 blocks from jpeg content string. Motivation: APP1 blocks contain changes like render date, that don't really mean the image has changed in any meaningful way. This function supports, lax jpeg file change detection. Instructions: Remove app1 blocks from souchgDete & target contents, then compare the results to decide if there are any meaningful differences.
Parameters:
-
contents
:
-
- JpegUtils.writeFileWithChgDetMetadata (filePath, contents, metadata)
-
Synopsis: Combine metadata with file contents and write to disk. Motivation: Supports Photooey which needs to write a newly rendered file to target with metadata. Returns: - true, nil: worked - no comment. - true, comment: pretended to work - test mode qualification. - false, error-message: failed. Notes: - Since contents comes from rendered file, it won't have metadata to be replaced, so can write as new.
Parameters:
-
filePath
: -
contents
: -
metadata
:
-
- JpegUtils.writeFileWithMetadata (filePath, contents, metadata, metadataSignature, blockType)
-
Write file with metadata.
Parameters:
-
filePath
: -
contents
: -
metadata
: -
metadataSignature
: -
blockType
:
-