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.
- Host: GitHub
- URL: https://github.com/moustikitos/tyf
- Owner: Moustikitos
- Created: 2015-11-22T08:43:39.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2023-07-29T17:57:09.000Z (about 2 years ago)
- Last Synced: 2025-04-13T05:05:28.364Z (6 months ago)
- Topics: exif, geotiff, gps, ifd, jpeg, tiff, xmp
- Language: Python
- Homepage:
- Size: 22.9 MB
- Stars: 19
- Watchers: 3
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `Tyf`
[](https://htmlpreview.github.io/?https://github.com/Moustikitos/tyf/blob/master/tyf.html)
[](https://pypi.python.org/pypi/Tyf)
[](https://pypi.python.org/pypi/Tyf)
[](https://pypi.python.org/pypi/Tyf)
[](https://pepy.tech/project/tyf)## Support this project
[](https://liberapay.com/Toons/donate)
[](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
```
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")
```
```python
>>> jpg.ifd0.set_location(4.362859, 48.958472, 0)
>>> ifd.dump_mapbox_location(jpg.ifd0, "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