Skip to content

Commit

Permalink
Add README to the package
Browse files Browse the repository at this point in the history
  • Loading branch information
dev0x13 committed Mar 13, 2024
1 parent 2ebe6b1 commit 81dbfd3
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,44 @@ cmake -A x64 ..
cmake --build .
```

## Usage example

The example below demonstrates how to decode a PNG image and its EXIF metadata:

```python
from pywuffs import ImageDecoderType, PixelFormat
from pywuffs.aux import (
ImageDecoder,
ImageDecoderConfig,
ImageDecoderFlags
)

config = ImageDecoderConfig()

# All decoders are enabled by default
config.enabled_decoders = [ImageDecoderType.PNG]

# No metadata is reported by default
config.flags = [ImageDecoderFlags.REPORT_METADATA_EXIF]

# Pixel format is PixelFormat.BGRA_PREMUL by default
config.pixel_format = PixelFormat.BGR

decoder = ImageDecoder(config)

decoding_result = decoder.decode("lena.png")

# Decoded image data in BGR format
image_data = decoding_result.pixbuf

# Shape of the decoded image
image_shape = decoding_result.pixbuf.shape

# Parsed EXIF metadata
meta_minfo = decoding_result.reported_metadata[0].minfo
meta_bytes = decoding_result.reported_metadata[0].data.tobytes()
```

## API reference

API documentation is available at https://pywuffs.readthedocs.io.
Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
from setuptools import setup
from pybind11.setup_helpers import Pybind11Extension
from setuptools.command.build_ext import build_ext
from pathlib import Path

long_description = (Path(__file__).parent / "README.md").read_text()

UNIX_BUILD_ARGS = ["-O3", "-g0", "-s", "--std=c++14",
"-fvisibility=hidden", "-flto", "-fno-fat-lto-objects"]
Expand Down Expand Up @@ -38,9 +41,11 @@ def build_extensions(self):
]

setup(name="pywuffs",
version="1.2.0",
version="1.2.1",
description="Python bindings for Wuffs the Library",
author="Georgiy Manuilov",
url="https://github.com/dev0x13/pywuffs",
cmdclass={"build_ext": CustomBuildExt},
long_description=long_description,
long_description_content_type="text/markdown",
ext_modules=ext_modules)

0 comments on commit 81dbfd3

Please sign in to comment.