Streamlined JPEG image metadata parsing and updating.
Project description
JPEGData
The JPEGData library for Python provides a streamlined way to work with JPEG image files offering the ability to extract certain file metadata.
Requirements
The JPEGData library has been tested to work with Python 3.10, 3.11, 3.12 and 3.13, but has not been tested, nor is its use supported with earlier versions of Python.
Installation
The library is available from the PyPI repository, so may be added easily to a project's
dependencies via its requirements.txt file or similar by referencing the library's
name, jpegdata, or the library may be installed directly onto your local development
system using pip install by entering the following command:
$ pip install jpegdata
Classes, Methods & Properties
The JPEGData library's main class is the JPEG class through which JPEG image files can
be loaded, modified via the supported actions, and saved. The library supports reading
several common JPEG file formats including JFIF, EXIF, CCIF and SPIFF formatted JPEG files.
Currently the library does not support more recent JPEG formats and derivations such as
JPEG XL, JPEG-2000, JPEG XR, etc.
The JPEG class offers the following methods:
JPEG(filepath: str)– TheJPEG()class constructor expects an absolute filepath at a minimum for the JPEG file you wish to open. Upon initialising the class with the file, the library will then attempt to load and parse the file. Assuming that the file is a valid JPEG file, the library will parse the file, identify any segments contained within the file, and any data associated with each of the segments, and will determine several intrinsic properties of the JPEG image including the canvas width and height.
The JPEG class offers the following properties:
info(Information) – Theinfoproperty can be used to access theInformationclass instance that is created when theJPEGclass instance is created and the file is parsed. TheInformationclass instance contains core information about the parsed file including thefilepath,filesize, (byte)order, andformat.
This property is used internally by the class to populate the corresponding top level properties of the same names noted below.
-
filepath(str) – Thefilepathproperty can be used to get the original file path that was specified at the time the class was initialised. -
filesize(int) – Thefilesizeproperty can be used to get the original file size of the file that was specified at the time the class was initialised. -
datetime_created(datetime) – Thedatetime_createdproperty can be used to access the date/time that the loaded JPEG file was created according to filesystem metadata. -
datetime_modified(datetime) – Thedatetime_modifiedproperty can be used to access the date/time that the loaded JPEG file was modified according to filesystem metadata. -
order(ByteOrder) – Theorderproperty can be used to determine the byte order of the JPEG file. As all JPEG files are encoded as big-endian, the property will always reportByteOrder.BigEndian. -
format(Format) – Theformatproperty can be used to determine the file format of the JPEG file. The property will report one of the followingFormatenumeration values:Format.JPEGfor baseline formatted JPEG files;Format.JFIFfor JPEG File Interchange Format (JFIF) formatted JPEG files;Format.EXIFfor Extensible Image Format (EXIF) formatted JPEG files;Format.CCIFfor Canon Camera Image File Format (CCIF) formatted JPEG files;Format.SPIFFfor Still Picture Interchange File Format (SPIFF) formatted JPEG files.
-
encoding(Encoding) – Theencodingproperty can be used to determine the encoding used for the JPEG file, which will report one of the followingEncodingenumeration values:Encoding.BaselineDCTfor baseline DCT encoded images;Encoding.ProgressiveDCTfor progressive DCT encoded images.
-
width(int) – Thewidthproperty can be used to access the parsed pixel width of the image. -
height(int) – Theheightproperty can be used to access the parsed pixel height of the image. -
precision(int) – Theprecisionproperty can be used to access the parsed precision of the image. -
transform(ColourTransform) – Thetransformproperty can be used to determine the colour transform used for the JPEG file, which will report one of the followingColourTransformenumeration values:ColourTransform.Unknownused when the colour transform cannot be determined.ColourTransform.RGBfor RGB images.ColourTransform.YCbCrfor YCbCr images.ColourTransform.YCCKfor YCCK images.ColourTransform.Greyscale(also available as the aliasedGrayscale) for greyscale images.ColourTransform.CMYKfor CMYK images.
-
components(int) – Thecomponentsproperty can be used to determine the number of colour components used for the JPEG file, reported as an integer value.
Example of Use
To create an instance of the JPEG class, import the JPEG class from the library and
specify the absolute file path to the JPEG file you wish to open as the first argument.
If the specified file can be opened successfully, the library will return an instance of
either the JPEG, JFIF, EXIF, CCIF or SPIFF subclasses, depending on the file
format of the specified JPEG file; these subclasses are all subclasses of the library's
JPEG base class.
from jpegdata import JPEG, Format, Encoding, ColourTransform
filepath = "/path/to/file.jpeg"
# Initialize the library with the absolute file path of the JPEG file to load
jpeg = JPEG(filepath=filepath)
assert isinstance(jpeg, JPEG)
# Use the parsed properties of the file
assert jpeg.format is Format.EXIF
assert jpeg.encoding is Encoding.BaselineDCT
assert jpeg.precision == 8
assert jpeg.width == 600
assert jpeg.height == 400
assert jpeg.components == 3
assert jpeg.transform is ColourTransform.YCbCr
# If desired, iterate through the segments held within the file:
for segment in jpeg:
print(segment)
Command Line Tool
The jpegdata command line tool, installed alongside the library, provides a command
line interface to print out the information parsed from the specified JPEG file.
The tool can print out the information directly to the command line either as plain text or as a JSON-serialised payload.
To print the help information for the tool, pass the --help argument.
$ jpegdata ./path/to/file.jpeg
The above command will generate output similar to the following:
File Name: ./path/to/file.jpeg
File Path: /absolute/path/to/file.jpeg
File Size: 3890 bytes
File Created Date: 2025-08-10 17:15:13.892694
File Modified Date: 2025-08-10 17:15:07.312874
Byte Order: MSB
Format: JPEG Extensible Image File (EXIF) format
Encoding: Baseline DCT
Image Width: 3 pixels
Image Height: 3 pixels
Image Size: 3x3 pixels
Megapixels: 0.000009
Bits Per Sample: 8
Colour Components: 3
Colour Transform: YCbCr
To emit the parsed information as a JSON-serialised payload, pass the --format json
argument to the command:
$ jpegdata ./path/to/file.jpeg --format json
The above command will generate output similar to the following:
{
"filename": "./path/to/file.jpeg",
"filepath": "/absolute/path/to/file.jpeg",
"filesize": 3890,
"filedate": {
"created": "2025-08-10 17:15:13.892694",
"modified": "2025-08-10 17:15:07.312874"
},
"byte_oder": "MSB",
"encoding": "BaselineDCT",
"precision": 8,
"width": 3,
"height": 3,
"colour": {
"components": 3,
"transform": "YCbCr"
}
}
To emit the verbose form of output, pass the --verbose argument, which will include
information about the parsed segment markers found in the file. This is included in both
the plain text and JSON-serialised output formats.
Disclaimer
While every effort has been made to ensure that the library works reliably with JPEG files and embedded metadata, you must ensure that all files are backed up before using the JPEGData library with any files, especially as the library is in early development.
Furthermore, the library may not be able to read nor preserve all metadata or other data within a JPEG file, especially if manufacturer specific, custom or other "private" data are present. As such, it is possible that loss of data could occur if an image is loaded and is then overwritten by saving the file back to the same file path, when saving is available in future versions of the library (currently the library is read-only).
Use of the library is entirely at your own risk and the authors bear no responsibility for losses of any kind. By using the software you assume all such risk and liability.
THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Credits & References
The JPEG file format, and the related EXIF, IPTC and XMP metadata model specifications were researched across various sources. Please visit these valuable online resources to learn more about the JPEG file format and related metadata model specifications and to support these world class organisations and their products:
-
JPEG File Format
- https://www.loc.gov/preservation/digital/formats/fdd/fdd000619.shtml
- https://en.wikipedia.org/wiki/JPEG (JPEG)
- https://en.wikipedia.org/wiki/JPEG_File_Interchange_Format (JFIF)
- https://www.loc.gov/preservation/digital/formats/fdd/fdd000018.shtml (JFIF)
- https://www.loc.gov/preservation/digital/formats/fdd/fdd000147.shtml (EXIF)
- https://cran.r-project.org/web/packages/ctypesio/vignettes/parse-jpeg.html
- https://dev.exiv2.org/projects/exiv2/wiki/The_Metadata_in_JPEG_files
-
EXIF Metadata Model & Fields
-
IPTC Metadata Model & Fields
-
XMP Metadata Model & Fields
Copyright & License Information
Copyright © 2025 Daniel Sissman; licensed under the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jpegdata-0.1.3.tar.gz.
File metadata
- Download URL: jpegdata-0.1.3.tar.gz
- Upload date:
- Size: 21.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9ebd90171d78948ed6759232183c7250add2fc0c2f7a786b59388452d3dbc61
|
|
| MD5 |
fee2c42920957d31610bd2fd477451e8
|
|
| BLAKE2b-256 |
790071c13d7c38d1b34e4dd5a360551a5e90ee7a26898b2d4af2ae17329d8387
|
Provenance
The following attestation bundles were made for jpegdata-0.1.3.tar.gz:
Publisher:
python-publish.yml on bluebinary/jpegdata
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jpegdata-0.1.3.tar.gz -
Subject digest:
d9ebd90171d78948ed6759232183c7250add2fc0c2f7a786b59388452d3dbc61 - Sigstore transparency entry: 493274263
- Sigstore integration time:
-
Permalink:
bluebinary/jpegdata@88a1387b75e8599e98d52d3a22b93eaff06654c8 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/bluebinary
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@88a1387b75e8599e98d52d3a22b93eaff06654c8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file jpegdata-0.1.3-py3-none-any.whl.
File metadata
- Download URL: jpegdata-0.1.3-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d334a7fb1e7591ad5fb78f4262a9a738f6d1556c2039ebb40ac11a7fe28b218a
|
|
| MD5 |
681bf605d270cd3905933e8874ef717d
|
|
| BLAKE2b-256 |
5118d61f85b87faa7c573f4876b80c110ea0d0f254b9e0a20adfdcf4c14da3a9
|
Provenance
The following attestation bundles were made for jpegdata-0.1.3-py3-none-any.whl:
Publisher:
python-publish.yml on bluebinary/jpegdata
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
jpegdata-0.1.3-py3-none-any.whl -
Subject digest:
d334a7fb1e7591ad5fb78f4262a9a738f6d1556c2039ebb40ac11a7fe28b218a - Sigstore transparency entry: 493274276
- Sigstore integration time:
-
Permalink:
bluebinary/jpegdata@88a1387b75e8599e98d52d3a22b93eaff06654c8 -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/bluebinary
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@88a1387b75e8599e98d52d3a22b93eaff06654c8 -
Trigger Event:
release
-
Statement type: