An open API service indexing awesome lists of open source software.

https://github.com/moustikitos/tyf

Manipulate EXIF and IFD metadata.
https://github.com/moustikitos/tyf

exif geotiff gps ifd jpeg tiff xmp

Last synced: 6 months ago
JSON representation

Manipulate EXIF and IFD metadata.

Awesome Lists containing this project

README

          

# `Tyf`

[![pypi](https://img.shields.io/pypi/l/Tyf.svg)](https://htmlpreview.github.io/?https://github.com/Moustikitos/tyf/blob/master/tyf.html)
[![pypi](https://img.shields.io/pypi/pyversions/Tyf.svg)](https://pypi.python.org/pypi/Tyf)
[![pypi](https://img.shields.io/pypi/v/Tyf.svg)](https://pypi.python.org/pypi/Tyf)
[![pypi](https://img.shields.io/badge/wheel-yes-brightgreen.svg)](https://pypi.python.org/pypi/Tyf)
[![Downloads](https://pepy.tech/badge/Tyf/week)](https://pepy.tech/project/tyf)

## Support this project

[![Liberapay receiving](https://img.shields.io/liberapay/goal/Toons?logo=liberapay)](https://liberapay.com/Toons/donate)
[![Paypal me](https://img.shields.io/badge/PayPal-00457C?logo=paypal&logoColor=white)](https://paypal.me/toons)

## Why this package ?

Tyf package provides pythonic way to work with embeded data in TIFF and JPEG images.

## Documentation

[The Tyf Project [WIP]](https://moustikitos.github.io/tyf/)

### Read / write EXIF and IFD data

+ read / edit EXIF and XMP data from JPEG images
+ read / edit IFD and XMP data from TIFF images
+ read / edit / use GEOTIFF data from IFD
+ work directly with python types

### Do more with JPEG and TIFF files

+ extract TIFF or JPEG thumbnails from JPEG files
+ dump EXIF data from JPEG into file
+ dump location thumbnail using any map provider API

## Quick view

```python
>>> import Tyf
>>> tif = Tyf.open("test/CEA.tif")
>>> tif.__class__

>>> for key in tif.gkd[0]: print(key)
...

>>> tr = tif[0].getModelTransformation()
>>> tr(tif[0]["ImageWidth"]/2, tif[0]["ImageLength"]/2)
(-13067.47757973173, 4240428.8435290195, 0.0)
>>> jpg = Tyf.open("test/IMG_20150730_210115.jpg")
unknown tag 18246 type [7]: ignored
unknown tag 18249 type [7]: ignored
>>> jpg.__class__

>>> jpg["XPComment"]

>>> jpg.xmp

>>> jpg.get_xmp("Rating", ns="ADOBE").text
'4'
>>> jpg.set_xmp("UserComment", "Simple comment")

>>> jpg.get_xmp("UserComment").text
'Simple comment'
>>> jpg.save_thumbnail("test/test_thumb") # extension automatically added
```

![EXIF thumbnail](https://raw.githubusercontent.com/Moustikitos/tyf/master/test/test_thumb.jpg)

There are 3 attributes to access data within `Tyf.JpegFile` :

+ ``ifd0`` containing picture IFD, EXIF and eventually GPS data
+ ``ifd1`` containing thubnail data
+ ``xmp`` containing XMP data

`ifd0` and `ifd1` are shortcut to the first and second IFD in `ifd` attribute which is itself a `Tyf.TiffFile`.

```python
>>> jpg.ifd[0] == jpg.ifd0
True
>>> jpg.ifd[1] == jpg.ifd1
True
>>> jpg.ifd.__class__

>>> jpg.ifd0[256]
2560
>>> jpg.ifd0["ImageWidth"]
2560
>>> jpg.ifd0[256], jpg.ifd0.get("ImageWidth").comment
(2560, 'Number of columns in the image, ie, the number of pixels per row')
>>> jpg.ifd0["GPSLongitude"]
5.1872093
```

### `Tyf.ifd.Ifd` class

```python
>>> jpg.ifd0.__class__

>>> for tag in jpg.ifd0.tags(): print(tag)
...

>>> jpg.ifd0.get("Orientation").info
'Normal'
>>> jpg.ifd0.get_location()
(5.1872093, 51.2095416, -0.0)
>>> from Tyf import ifd
>>> ifd.dump_mapbox_location(jpg.ifd0, "test/test_location.png")
```

![5.1872093, 51.2095416](https://raw.githubusercontent.com/Moustikitos/tyf/master/test/test_location.png)

```python
>>> jpg.ifd0.set_location(4.362859, 48.958472, 0)
>>> ifd.dump_mapbox_location(jpg.ifd0, "test/test_location2.png")
```

![4.362859, 48.958472](https://raw.githubusercontent.com/Moustikitos/tyf/master/test/test_location2.png)

## Contribute
### Bug report & feedback
Use project issues.

### Add / modify / fix code
Guidance words: keep it simple and solid!

1. open a issue to propose your contribution
2. once issue is granted
+ fork this repository
+ edit your contribution
+ start a pull request