Tyf


NameTyf JSON
Version 1.5.1 PyPI version JSON
download
home_pagehttps://github.com/Moustikitos/Tyf
SummaryPythonic way to read and edit IFD and EXIF tags.
upload_time2023-07-28 06:26:48
maintainerBruno THOORENS
docs_urlhttps://pythonhosted.org/Tyf/
authorBruno THOORENS
requires_python
licenseCopyright 2015-2020, THOORENS Bruno, BSD licence
keywords ifd tiff jpeg exif gps geotiff pil pillow xmp
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # `Tyf`
## Copyright
[![pypi](https://img.shields.io/pypi/l/Tyf.svg)](https://htmlpreview.github.io/?https://github.com/Moustikitos/tyf/blob/master/tyf.html)

## Distribution
[![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)

[Buy Ѧ](https://bittrex.com/Account/Register?referralCode=NW5-DQO-QMT) and:

 + [X] Send Ѧ to `AUahWfkfr5J4tYakugRbfow7RWVTK35GPW`
 + [X] Vote `arky` on [Ark blockchain](https://explorer.ark.io) and [earn Ѧ weekly](http://dpos.arky-delegate.info/arky)

## 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 data from JPEG images
 + read / edit IFD data from TIFF images
 + read / edit GEOTIFF data from IFD
 + read / edit XMP data from IFD and JPEG images
 + work directly with python numbers, string and datetime
 + interpolate map coordinates using GEOTIFF ModelTransformation

### 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
>>> jpg = Tyf.open("test/IMG_20150730_210115.jpg")
>>> jpg.__class__
<class 'Tyf.JpegFile'>
>>> print(Tyf.xmp.tostring(jpg.xmp).decode()) 
<ns0:xmpmeta
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 xmlns:ns0="adobe:ns:meta/" xmlns:ns3="http://ns.adobe.com/xap/1.0/"
 xmlns:ns4="http://ns.microsoft.com/photo/1.0/"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:RDF>
<rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b">
<dc:title><rdf:Alt><rdf:li xml:lang="x-default">Beautifull Rainbow</rdf:li>
</rdf:Alt></dc:title><dc:description><rdf:Alt>
<rdf:li xml:lang="x-default">Beautifull Rainbow</rdf:li></rdf:Alt>
</dc:description><dc:creator><rdf:Seq><rdf:li>THOORENS Bruno</rdf:li>
</rdf:Seq></dc:creator><dc:rights><rdf:Alt>
<rdf:li xml:lang="x-default">THOORENS Bruno</rdf:li></rdf:Alt></dc:rights>
</rdf:Description>
<rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b" />
<rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b">
<ns3:Rating>4</ns3:Rating></rdf:Description>
<rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b">
<ns4:Rating>75</ns4:Rating><ns4:LastKeywordXMP><rdf:Bag>
<rdf:li>Rainbow</rdf:li><rdf:li>Belgium</rdf:li></rdf:Bag>
</ns4:LastKeywordXMP></rdf:Description>
<rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b">
<dc:subject><rdf:Bag><rdf:li>Rainbow</rdf:li><rdf:li>Belgium</rdf:li></rdf:Bag>
</dc:subject></rdf:Description>
</rdf:RDF></ns0:xmpmeta>
>>> 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__
<class 'Tyf.TiffFile'>
>>> 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__
<class 'Tyf.ifd.Ifd'>
>>> for tag in jpg.ifd0.tags(): print(tag)
...
<IFD tag ImageWidth:2560>
<IFD tag ImageLength:1920>
<IFD tag Make:'Google'>
<IFD tag Model:'Nexus S'>
<IFD tag Orientation:1 - Normal>
<IFD tag Software:'KVT49L'>
<IFD tag DateTime:datetime.datetime(2015, 7, 30, 21, 1, 16)>
<IFD tag Artist:'THOORENS Bruno'>
<IFD tag YCbCrPositioning:1 - Centered>
<IFD tag Copyright:'THOORENS Bruno'>
<IFD tag Exif IFD:2286>
<IFD tag GPS IFD:4754>
<IFD tag XPTitle:'Beautifull Rainbow'>
<IFD tag XPComment:'For testing purpose only !'>
<IFD tag XPAuthor:'THOORENS Bruno'>
<IFD tag XPKeywords:'Rainbow;Belgium'>
<IFD tag ExposureTime:0.008333333333333333>
<IFD tag FNumber:2.6>
<IFD tag ExposureProgram:3 - Aperture priority>
<IFD tag ISOSpeedRatings:50>
<IFD tag ExifVersion:b'0220'>
<IFD tag DateTimeOriginal:datetime.datetime(2015, 7, 30, 21, 1, 16)>
<IFD tag DateTimeDigitized:datetime.datetime(2015, 7, 30, 21, 1, 16)>
<IFD tag ShutterSpeedValue:7.0>
<IFD tag ApertureValue:3.0>
<IFD tag BrightnessValue:6.0>
<IFD tag ExposureBiasValue:0.0>
<IFD tag MaxApertureValue:3.0>
<IFD tag MeteringMode:2 - Center Weighted Average>
<IFD tag Flash:0 - Flash did not fire>
<IFD tag FocalLength:3.43>
<IFD tag ColorSpace:1 - RGB>
<IFD tag PixelXDimension:2560>
<IFD tag PixelYDimension:1920>
<IFD tag ExposureMode:0 - Auto exposure>
<IFD tag WhiteBalance:0 - Auto white balance>
<IFD tag SceneCaptureType:0 - Standard>
<IFD tag GPSVersionID:(2, 2, 0, 0)>
<IFD tag GPSLatitudeRef:'N'>
<IFD tag GPSLatitude:51.2095416>
<IFD tag GPSLongitudeRef:'E'>
<IFD tag GPSLongitude:5.1872093>
<IFD tag GPSAltitudeRef:0 - Above sea level>
<IFD tag GPSAltitude:0.0>
<IFD tag GPSTimeStamp:datetime.time(19, 1, 7)>
<IFD tag GPSImgDirectionRef:'M'>
<IFD tag GPSImgDirection:33.0>
<IFD tag GPSProcessingMethod:b'ASCII\x00\x00\x00NETWORK'>
<IFD tag GPSDateStamp:datetime.date(2015, 7, 30)>
>>> 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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Moustikitos/Tyf",
    "name": "Tyf",
    "maintainer": "Bruno THOORENS",
    "docs_url": "https://pythonhosted.org/Tyf/",
    "requires_python": "",
    "maintainer_email": "moustikitos@gmail.com",
    "keywords": "ifd,tiff,jpeg,exif,gps,geotiff,PIL,Pillow,xmp",
    "author": "Bruno THOORENS",
    "author_email": "moustikitos@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ee/03/9c5bfe4248809273fdcebfd9e603845adcc605c2caf6e9e3996b0ded182a/Tyf-1.5.1.tar.gz",
    "platform": null,
    "description": "# `Tyf`\r\n## Copyright\r\n[![pypi](https://img.shields.io/pypi/l/Tyf.svg)](https://htmlpreview.github.io/?https://github.com/Moustikitos/tyf/blob/master/tyf.html)\r\n\r\n## Distribution\r\n[![pypi](https://img.shields.io/pypi/pyversions/Tyf.svg)](https://pypi.python.org/pypi/Tyf)\r\n[![pypi](https://img.shields.io/pypi/v/Tyf.svg)](https://pypi.python.org/pypi/Tyf)\r\n[![pypi](https://img.shields.io/badge/wheel-yes-brightgreen.svg)](https://pypi.python.org/pypi/Tyf)\r\n[![Downloads](https://pepy.tech/badge/Tyf/week)](https://pepy.tech/project/tyf)\r\n\r\n## Support this project\r\n[![Liberapay receiving](https://img.shields.io/liberapay/goal/Toons?logo=liberapay)](https://liberapay.com/Toons/donate)\r\n\r\n[Buy &#1126;](https://bittrex.com/Account/Register?referralCode=NW5-DQO-QMT) and:\r\n\r\n + [X] Send &#1126; to `AUahWfkfr5J4tYakugRbfow7RWVTK35GPW`\r\n + [X] Vote `arky` on [Ark blockchain](https://explorer.ark.io) and [earn &#1126; weekly](http://dpos.arky-delegate.info/arky)\r\n\r\n## Why this package ?\r\nTyf package provides pythonic way to work with embeded data in TIFF and JPEG images.\r\n\r\n## Documentation\r\n[The Tyf Project [WIP]](https://moustikitos.github.io/tyf/)\r\n\r\n### Read / write EXIF and IFD data\r\n + read / edit EXIF data from JPEG images\r\n + read / edit IFD data from TIFF images\r\n + read / edit GEOTIFF data from IFD\r\n + read / edit XMP data from IFD and JPEG images\r\n + work directly with python numbers, string and datetime\r\n + interpolate map coordinates using GEOTIFF ModelTransformation\r\n\r\n### Do more with JPEG and TIFF files\r\n + extract TIFF or JPEG thumbnails from JPEG files\r\n + dump EXIF data from JPEG into file\r\n + dump location thumbnail using any map provider API\r\n\r\n## Quick view\r\n```python\r\n>>> import Tyf\r\n>>> jpg = Tyf.open(\"test/IMG_20150730_210115.jpg\")\r\n>>> jpg.__class__\r\n<class 'Tyf.JpegFile'>\r\n>>> print(Tyf.xmp.tostring(jpg.xmp).decode()) \r\n<ns0:xmpmeta\r\n xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\r\n xmlns:ns0=\"adobe:ns:meta/\" xmlns:ns3=\"http://ns.adobe.com/xap/1.0/\"\r\n xmlns:ns4=\"http://ns.microsoft.com/photo/1.0/\"\r\n xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"><rdf:RDF>\r\n<rdf:Description rdf:about=\"uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b\">\r\n<dc:title><rdf:Alt><rdf:li xml:lang=\"x-default\">Beautifull Rainbow</rdf:li>\r\n</rdf:Alt></dc:title><dc:description><rdf:Alt>\r\n<rdf:li xml:lang=\"x-default\">Beautifull Rainbow</rdf:li></rdf:Alt>\r\n</dc:description><dc:creator><rdf:Seq><rdf:li>THOORENS Bruno</rdf:li>\r\n</rdf:Seq></dc:creator><dc:rights><rdf:Alt>\r\n<rdf:li xml:lang=\"x-default\">THOORENS Bruno</rdf:li></rdf:Alt></dc:rights>\r\n</rdf:Description>\r\n<rdf:Description rdf:about=\"uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b\" />\r\n<rdf:Description rdf:about=\"uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b\">\r\n<ns3:Rating>4</ns3:Rating></rdf:Description>\r\n<rdf:Description rdf:about=\"uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b\">\r\n<ns4:Rating>75</ns4:Rating><ns4:LastKeywordXMP><rdf:Bag>\r\n<rdf:li>Rainbow</rdf:li><rdf:li>Belgium</rdf:li></rdf:Bag>\r\n</ns4:LastKeywordXMP></rdf:Description>\r\n<rdf:Description rdf:about=\"uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b\">\r\n<dc:subject><rdf:Bag><rdf:li>Rainbow</rdf:li><rdf:li>Belgium</rdf:li></rdf:Bag>\r\n</dc:subject></rdf:Description>\r\n</rdf:RDF></ns0:xmpmeta>\r\n>>> jpg.save_thumbnail(\"test/test_thumb\") # extension automatically added\r\n```\r\n\r\n![EXIF thumbnail](https://raw.githubusercontent.com/Moustikitos/tyf/master/test/test_thumb.jpg)\r\n\r\nThere are 3 attributes to access data within `Tyf.JpegFile` :\r\n\r\n+ ``ifd0`` containing picture IFD, EXIF and eventually GPS data \r\n+ ``ifd1`` containing thubnail data\r\n+ ``xmp`` containing XMP data\r\n\r\n`ifd0` and `ifd1` are shortcut to the first and second IFD in `ifd` attribute which is itself a `Tyf.TiffFile`.\r\n\r\n```python\r\n>>> jpg.ifd[0] == jpg.ifd0\r\nTrue\r\n>>> jpg.ifd[1] == jpg.ifd1\r\nTrue\r\n>>> jpg.ifd.__class__\r\n<class 'Tyf.TiffFile'>\r\n>>> jpg.ifd0[256]\r\n2560\r\n>>> jpg.ifd0[\"ImageWidth\"]\r\n2560\r\n>>> jpg.ifd0[256], jpg.ifd0.get(\"ImageWidth\").comment\r\n(2560, 'Number of columns in the image, ie, the number of pixels per row')\r\n>>> jpg.ifd0[\"GPSLongitude\"]\r\n5.1872093\r\n```\r\n\r\n### `Tyf.ifd.Ifd` class\r\n\r\n```python\r\n>>> jpg.ifd0.__class__\r\n<class 'Tyf.ifd.Ifd'>\r\n>>> for tag in jpg.ifd0.tags(): print(tag)\r\n...\r\n<IFD tag ImageWidth:2560>\r\n<IFD tag ImageLength:1920>\r\n<IFD tag Make:'Google'>\r\n<IFD tag Model:'Nexus S'>\r\n<IFD tag Orientation:1 - Normal>\r\n<IFD tag Software:'KVT49L'>\r\n<IFD tag DateTime:datetime.datetime(2015, 7, 30, 21, 1, 16)>\r\n<IFD tag Artist:'THOORENS Bruno'>\r\n<IFD tag YCbCrPositioning:1 - Centered>\r\n<IFD tag Copyright:'THOORENS Bruno'>\r\n<IFD tag Exif IFD:2286>\r\n<IFD tag GPS IFD:4754>\r\n<IFD tag XPTitle:'Beautifull Rainbow'>\r\n<IFD tag XPComment:'For testing purpose only !'>\r\n<IFD tag XPAuthor:'THOORENS Bruno'>\r\n<IFD tag XPKeywords:'Rainbow;Belgium'>\r\n<IFD tag ExposureTime:0.008333333333333333>\r\n<IFD tag FNumber:2.6>\r\n<IFD tag ExposureProgram:3 - Aperture priority>\r\n<IFD tag ISOSpeedRatings:50>\r\n<IFD tag ExifVersion:b'0220'>\r\n<IFD tag DateTimeOriginal:datetime.datetime(2015, 7, 30, 21, 1, 16)>\r\n<IFD tag DateTimeDigitized:datetime.datetime(2015, 7, 30, 21, 1, 16)>\r\n<IFD tag ShutterSpeedValue:7.0>\r\n<IFD tag ApertureValue:3.0>\r\n<IFD tag BrightnessValue:6.0>\r\n<IFD tag ExposureBiasValue:0.0>\r\n<IFD tag MaxApertureValue:3.0>\r\n<IFD tag MeteringMode:2 - Center Weighted Average>\r\n<IFD tag Flash:0 - Flash did not fire>\r\n<IFD tag FocalLength:3.43>\r\n<IFD tag ColorSpace:1 - RGB>\r\n<IFD tag PixelXDimension:2560>\r\n<IFD tag PixelYDimension:1920>\r\n<IFD tag ExposureMode:0 - Auto exposure>\r\n<IFD tag WhiteBalance:0 - Auto white balance>\r\n<IFD tag SceneCaptureType:0 - Standard>\r\n<IFD tag GPSVersionID:(2, 2, 0, 0)>\r\n<IFD tag GPSLatitudeRef:'N'>\r\n<IFD tag GPSLatitude:51.2095416>\r\n<IFD tag GPSLongitudeRef:'E'>\r\n<IFD tag GPSLongitude:5.1872093>\r\n<IFD tag GPSAltitudeRef:0 - Above sea level>\r\n<IFD tag GPSAltitude:0.0>\r\n<IFD tag GPSTimeStamp:datetime.time(19, 1, 7)>\r\n<IFD tag GPSImgDirectionRef:'M'>\r\n<IFD tag GPSImgDirection:33.0>\r\n<IFD tag GPSProcessingMethod:b'ASCII\\x00\\x00\\x00NETWORK'>\r\n<IFD tag GPSDateStamp:datetime.date(2015, 7, 30)>\r\n>>> jpg.ifd0.get(\"Orientation\").info\r\n'Normal'\r\n>>> jpg.ifd0.get_location()\r\n(5.1872093, 51.2095416, -0.0)\r\n>>> from Tyf import ifd\r\n>>> ifd.dump_mapbox_location(jpg.ifd0, \"test/test_location.png\")\r\n```\r\n\r\n![5.1872093, 51.2095416](https://raw.githubusercontent.com/Moustikitos/tyf/master/test/test_location.png)\r\n\r\n```python\r\n>>> jpg.ifd0.set_location(4.362859, 48.958472, 0)\r\n>>> ifd.dump_mapbox_location(jpg.ifd0, \"test/test_location2.png\")\r\n```\r\n\r\n![4.362859, 48.958472](https://raw.githubusercontent.com/Moustikitos/tyf/master/test/test_location2.png)\r\n\r\n## Contribute\r\n### Bug report & feedback\r\nUse project issues.\r\n\r\n### Add / modify / fix code\r\nGuidance words: keep it simple and solid!\r\n\r\n1. open a issue to propose your contribution\r\n2. once issue is granted\r\n    + fork this repository\r\n    + edit your contribution\r\n    + start a pull request\r\n",
    "bugtrack_url": null,
    "license": "Copyright 2015-2020, THOORENS Bruno, BSD licence",
    "summary": "Pythonic way to read and edit IFD and EXIF tags.",
    "version": "1.5.1",
    "project_urls": {
        "Download": "https://github.com/Moustikitos/tyf/archive/master.zip",
        "Homepage": "https://github.com/Moustikitos/Tyf"
    },
    "split_keywords": [
        "ifd",
        "tiff",
        "jpeg",
        "exif",
        "gps",
        "geotiff",
        "pil",
        "pillow",
        "xmp"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b1f80e39d7ab6579ea2703ba1138bced2af496f37ea3ddb3be070fa92374e96c",
                "md5": "8170f56665529a8ab4932bbeb562a33f",
                "sha256": "2cc58b0d936b47545d239f94deac3bc278147c26a828d45de0d41593bb156c13"
            },
            "downloads": -1,
            "filename": "Tyf-1.5.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8170f56665529a8ab4932bbeb562a33f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 92088,
            "upload_time": "2023-07-28T06:27:15",
            "upload_time_iso_8601": "2023-07-28T06:27:15.860926Z",
            "url": "https://files.pythonhosted.org/packages/b1/f8/0e39d7ab6579ea2703ba1138bced2af496f37ea3ddb3be070fa92374e96c/Tyf-1.5.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ee039c5bfe4248809273fdcebfd9e603845adcc605c2caf6e9e3996b0ded182a",
                "md5": "65804ee0f26602b8cfeced13f394d698",
                "sha256": "0ec8381b69ace3ba43e731e526935639551d1892f94a3ae3e28cb4ce22f1e545"
            },
            "downloads": -1,
            "filename": "Tyf-1.5.1.tar.gz",
            "has_sig": false,
            "md5_digest": "65804ee0f26602b8cfeced13f394d698",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 91920,
            "upload_time": "2023-07-28T06:26:48",
            "upload_time_iso_8601": "2023-07-28T06:26:48.303505Z",
            "url": "https://files.pythonhosted.org/packages/ee/03/9c5bfe4248809273fdcebfd9e603845adcc605c2caf6e9e3996b0ded182a/Tyf-1.5.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-28 06:26:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Moustikitos",
    "github_project": "Tyf",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tyf"
}
        
Elapsed time: 0.10301s