%global _empty_manifest_terminate_build 0 Name: python-pylibjpeg Version: 1.4.0 Release: 1 Summary: A Python framework for decoding JPEG and decoding/encoding DICOM RLE data, with a focus on supporting pydicom License: MIT URL: https://github.com/pydicom/pylibjpeg Source0: https://mirrors.nju.edu.cn/pypi/web/packages/2c/4d/151addc56b7cc9e138d5d83d5acb0a869239b709a8cf8898afdd88fd495d/pylibjpeg-1.4.0.tar.gz BuildArch: noarch Requires: python3-numpy Requires: python3-pylibjpeg-libjpeg Requires: python3-pylibjpeg-openjpeg Requires: python3-pylibjpeg-rle Requires: python3-pylibjpeg-libjpeg Requires: python3-pylibjpeg-openjpeg Requires: python3-pylibjpeg-rle %description [![codecov](https://codecov.io/gh/pydicom/pylibjpeg/branch/master/graph/badge.svg)](https://codecov.io/gh/pydicom/pylibjpeg) [![Build Status](https://github.com/pydicom/pylibjpeg/workflows/build/badge.svg)](https://github.com/pydicom/pylibjpeg/actions?query=workflow%3Abuild) [![PyPI version](https://badge.fury.io/py/pylibjpeg.svg)](https://badge.fury.io/py/pylibjpeg) [![Python versions](https://img.shields.io/pypi/pyversions/pylibjpeg.svg)](https://img.shields.io/pypi/pyversions/pylibjpeg.svg) ## pylibjpeg A Python 3.7+ framework for decoding JPEG images and decoding/encoding RLE datasets, with a focus on providing support for [pydicom](https://github.com/pydicom/pydicom). ### Installation #### Installing the current release ``` pip install pylibjpeg ``` ##### Installing extra requirements The package can be installed with extra requirements to enable support for JPEG (with `libjpeg`), JPEG 2000 (with `openjpeg`) and Run-Length Encoding (RLE) (with `rle`), respectively: ``` pip install pylibjpeg[libjpeg,openjpeg,rle] ``` Or alternatively with just `all`: ``` pip install pylibjpeg[all] ``` #### Installing the development version Make sure [Git](https://git-scm.com/) is installed, then ```bash git clone https://github.com/pydicom/pylibjpeg python -m pip install pylibjpeg ``` ### Plugins One or more plugins are required before *pylibjpeg* is able to handle JPEG images or RLE datasets. To handle a given format or DICOM Transfer Syntax you first have to install the corresponding package: #### Supported Formats |Format |Decode?|Encode?|Plugin |Based on | |--- |------ |--- |--- |--- | |JPEG, JPEG-LS and JPEG XT|Yes |No |[pylibjpeg-libjpeg][1] |[libjpeg][2] | |JPEG 2000 |Yes |No |[pylibjpeg-openjpeg][3]|[openjpeg][4]| |RLE Lossless (PackBits) |Yes |Yes |[pylibjpeg-rle][5] |- | #### DICOM Transfer Syntax |UID | Description | Plugin | |--- |--- |---- | |1.2.840.10008.1.2.4.50|JPEG Baseline (Process 1) |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.51|JPEG Extended (Process 2 and 4) |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.57|JPEG Lossless, Non-Hierarchical (Process 14) |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.70|JPEG Lossless, Non-Hierarchical, First-Order Prediction
(Process 14, Selection Value 1) | [pylibjpeg-libjpeg][1]| |1.2.840.10008.1.2.4.80|JPEG-LS Lossless |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.81|JPEG-LS Lossy (Near-Lossless) Image Compression |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.90|JPEG 2000 Image Compression (Lossless Only) |[pylibjpeg-openjpeg][4]| |1.2.840.10008.1.2.4.91|JPEG 2000 Image Compression |[pylibjpeg-openjpeg][4]| |1.2.840.10008.1.2.5 |RLE Lossless |[pylibjpeg-rle][5] | If you're not sure what the dataset's *Transfer Syntax UID* is, it can be determined with: ```python >>> from pydicom import dcmread >>> ds = dcmread('path/to/dicom_file') >>> ds.file_meta.TransferSyntaxUID.name ``` [1]: https://github.com/pydicom/pylibjpeg-libjpeg [2]: https://github.com/thorfdbg/libjpeg [3]: https://github.com/pydicom/pylibjpeg-openjpeg [4]: https://github.com/uclouvain/openjpeg [5]: https://github.com/pydicom/pylibjpeg-rle ### Usage #### Decoding ##### With pydicom Assuming you have *pydicom* v2.1+ and suitable plugins installed: ```python from pydicom import dcmread from pydicom.data import get_testdata_file # With the pylibjpeg-libjpeg plugin ds = dcmread(get_testdata_file('JPEG-LL.dcm')) jpg_arr = ds.pixel_array # With the pylibjpeg-openjpeg plugin ds = dcmread(get_testdata_file('JPEG2000.dcm')) j2k_arr = ds.pixel_array # With the pylibjpeg-rle plugin and pydicom v2.2+ ds = dcmread(get_testdata_file('OBXXXX1A_rle.dcm')) # pydicom defaults to the numpy handler for RLE so need # to explicitly specify the use of pylibjpeg ds.decompress("pylibjpeg") rle_arr = ds.pixel_array ``` For datasets with multiple frames you can reduce your memory usage by processing each frame separately using the ``generate_frames()`` generator function: ```python from pydicom import dcmread from pydicom.data import get_testdata_file from pydicom.pixel_data_handlers.pylibjpeg_handler import generate_frames ds = dcmread(get_testdata_file('color3d_jpeg_baseline.dcm')) frames = generate_frames(ds) arr = next(frames) ``` ##### Standalone JPEG decoding You can also just use *pylibjpeg* to decode JPEG images to a [numpy ndarray](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html), provided you have a suitable plugin installed: ```python from pylibjpeg import decode # Can decode using the path to a JPG file as str or path-like arr = decode('filename.jpg') # Or a file-like... with open('filename.jpg', 'rb') as f: arr = decode(f) # Or bytes... with open('filename.jpg', 'rb') as f: arr = decode(f.read()) ``` #### Encoding ##### With pydicom Assuming you have *pydicom* v2.2+ and suitable plugins installed: ```python from pydicom import dcmread from pydicom.data import get_testdata_file from pydicom.uid import RLELossless ds = dcmread(get_testdata_file("CT_small.dcm")) # Encode in-place using RLE Lossless and update the dataset # Updates the Pixel Data, Transfer Syntax UID and Planar Configuration ds.compress(uid) # Save compressed ds.save_as("CT_small_rle.dcm") ``` %package -n python3-pylibjpeg Summary: A Python framework for decoding JPEG and decoding/encoding DICOM RLE data, with a focus on supporting pydicom Provides: python-pylibjpeg BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-pylibjpeg [![codecov](https://codecov.io/gh/pydicom/pylibjpeg/branch/master/graph/badge.svg)](https://codecov.io/gh/pydicom/pylibjpeg) [![Build Status](https://github.com/pydicom/pylibjpeg/workflows/build/badge.svg)](https://github.com/pydicom/pylibjpeg/actions?query=workflow%3Abuild) [![PyPI version](https://badge.fury.io/py/pylibjpeg.svg)](https://badge.fury.io/py/pylibjpeg) [![Python versions](https://img.shields.io/pypi/pyversions/pylibjpeg.svg)](https://img.shields.io/pypi/pyversions/pylibjpeg.svg) ## pylibjpeg A Python 3.7+ framework for decoding JPEG images and decoding/encoding RLE datasets, with a focus on providing support for [pydicom](https://github.com/pydicom/pydicom). ### Installation #### Installing the current release ``` pip install pylibjpeg ``` ##### Installing extra requirements The package can be installed with extra requirements to enable support for JPEG (with `libjpeg`), JPEG 2000 (with `openjpeg`) and Run-Length Encoding (RLE) (with `rle`), respectively: ``` pip install pylibjpeg[libjpeg,openjpeg,rle] ``` Or alternatively with just `all`: ``` pip install pylibjpeg[all] ``` #### Installing the development version Make sure [Git](https://git-scm.com/) is installed, then ```bash git clone https://github.com/pydicom/pylibjpeg python -m pip install pylibjpeg ``` ### Plugins One or more plugins are required before *pylibjpeg* is able to handle JPEG images or RLE datasets. To handle a given format or DICOM Transfer Syntax you first have to install the corresponding package: #### Supported Formats |Format |Decode?|Encode?|Plugin |Based on | |--- |------ |--- |--- |--- | |JPEG, JPEG-LS and JPEG XT|Yes |No |[pylibjpeg-libjpeg][1] |[libjpeg][2] | |JPEG 2000 |Yes |No |[pylibjpeg-openjpeg][3]|[openjpeg][4]| |RLE Lossless (PackBits) |Yes |Yes |[pylibjpeg-rle][5] |- | #### DICOM Transfer Syntax |UID | Description | Plugin | |--- |--- |---- | |1.2.840.10008.1.2.4.50|JPEG Baseline (Process 1) |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.51|JPEG Extended (Process 2 and 4) |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.57|JPEG Lossless, Non-Hierarchical (Process 14) |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.70|JPEG Lossless, Non-Hierarchical, First-Order Prediction
(Process 14, Selection Value 1) | [pylibjpeg-libjpeg][1]| |1.2.840.10008.1.2.4.80|JPEG-LS Lossless |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.81|JPEG-LS Lossy (Near-Lossless) Image Compression |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.90|JPEG 2000 Image Compression (Lossless Only) |[pylibjpeg-openjpeg][4]| |1.2.840.10008.1.2.4.91|JPEG 2000 Image Compression |[pylibjpeg-openjpeg][4]| |1.2.840.10008.1.2.5 |RLE Lossless |[pylibjpeg-rle][5] | If you're not sure what the dataset's *Transfer Syntax UID* is, it can be determined with: ```python >>> from pydicom import dcmread >>> ds = dcmread('path/to/dicom_file') >>> ds.file_meta.TransferSyntaxUID.name ``` [1]: https://github.com/pydicom/pylibjpeg-libjpeg [2]: https://github.com/thorfdbg/libjpeg [3]: https://github.com/pydicom/pylibjpeg-openjpeg [4]: https://github.com/uclouvain/openjpeg [5]: https://github.com/pydicom/pylibjpeg-rle ### Usage #### Decoding ##### With pydicom Assuming you have *pydicom* v2.1+ and suitable plugins installed: ```python from pydicom import dcmread from pydicom.data import get_testdata_file # With the pylibjpeg-libjpeg plugin ds = dcmread(get_testdata_file('JPEG-LL.dcm')) jpg_arr = ds.pixel_array # With the pylibjpeg-openjpeg plugin ds = dcmread(get_testdata_file('JPEG2000.dcm')) j2k_arr = ds.pixel_array # With the pylibjpeg-rle plugin and pydicom v2.2+ ds = dcmread(get_testdata_file('OBXXXX1A_rle.dcm')) # pydicom defaults to the numpy handler for RLE so need # to explicitly specify the use of pylibjpeg ds.decompress("pylibjpeg") rle_arr = ds.pixel_array ``` For datasets with multiple frames you can reduce your memory usage by processing each frame separately using the ``generate_frames()`` generator function: ```python from pydicom import dcmread from pydicom.data import get_testdata_file from pydicom.pixel_data_handlers.pylibjpeg_handler import generate_frames ds = dcmread(get_testdata_file('color3d_jpeg_baseline.dcm')) frames = generate_frames(ds) arr = next(frames) ``` ##### Standalone JPEG decoding You can also just use *pylibjpeg* to decode JPEG images to a [numpy ndarray](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html), provided you have a suitable plugin installed: ```python from pylibjpeg import decode # Can decode using the path to a JPG file as str or path-like arr = decode('filename.jpg') # Or a file-like... with open('filename.jpg', 'rb') as f: arr = decode(f) # Or bytes... with open('filename.jpg', 'rb') as f: arr = decode(f.read()) ``` #### Encoding ##### With pydicom Assuming you have *pydicom* v2.2+ and suitable plugins installed: ```python from pydicom import dcmread from pydicom.data import get_testdata_file from pydicom.uid import RLELossless ds = dcmread(get_testdata_file("CT_small.dcm")) # Encode in-place using RLE Lossless and update the dataset # Updates the Pixel Data, Transfer Syntax UID and Planar Configuration ds.compress(uid) # Save compressed ds.save_as("CT_small_rle.dcm") ``` %package help Summary: Development documents and examples for pylibjpeg Provides: python3-pylibjpeg-doc %description help [![codecov](https://codecov.io/gh/pydicom/pylibjpeg/branch/master/graph/badge.svg)](https://codecov.io/gh/pydicom/pylibjpeg) [![Build Status](https://github.com/pydicom/pylibjpeg/workflows/build/badge.svg)](https://github.com/pydicom/pylibjpeg/actions?query=workflow%3Abuild) [![PyPI version](https://badge.fury.io/py/pylibjpeg.svg)](https://badge.fury.io/py/pylibjpeg) [![Python versions](https://img.shields.io/pypi/pyversions/pylibjpeg.svg)](https://img.shields.io/pypi/pyversions/pylibjpeg.svg) ## pylibjpeg A Python 3.7+ framework for decoding JPEG images and decoding/encoding RLE datasets, with a focus on providing support for [pydicom](https://github.com/pydicom/pydicom). ### Installation #### Installing the current release ``` pip install pylibjpeg ``` ##### Installing extra requirements The package can be installed with extra requirements to enable support for JPEG (with `libjpeg`), JPEG 2000 (with `openjpeg`) and Run-Length Encoding (RLE) (with `rle`), respectively: ``` pip install pylibjpeg[libjpeg,openjpeg,rle] ``` Or alternatively with just `all`: ``` pip install pylibjpeg[all] ``` #### Installing the development version Make sure [Git](https://git-scm.com/) is installed, then ```bash git clone https://github.com/pydicom/pylibjpeg python -m pip install pylibjpeg ``` ### Plugins One or more plugins are required before *pylibjpeg* is able to handle JPEG images or RLE datasets. To handle a given format or DICOM Transfer Syntax you first have to install the corresponding package: #### Supported Formats |Format |Decode?|Encode?|Plugin |Based on | |--- |------ |--- |--- |--- | |JPEG, JPEG-LS and JPEG XT|Yes |No |[pylibjpeg-libjpeg][1] |[libjpeg][2] | |JPEG 2000 |Yes |No |[pylibjpeg-openjpeg][3]|[openjpeg][4]| |RLE Lossless (PackBits) |Yes |Yes |[pylibjpeg-rle][5] |- | #### DICOM Transfer Syntax |UID | Description | Plugin | |--- |--- |---- | |1.2.840.10008.1.2.4.50|JPEG Baseline (Process 1) |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.51|JPEG Extended (Process 2 and 4) |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.57|JPEG Lossless, Non-Hierarchical (Process 14) |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.70|JPEG Lossless, Non-Hierarchical, First-Order Prediction
(Process 14, Selection Value 1) | [pylibjpeg-libjpeg][1]| |1.2.840.10008.1.2.4.80|JPEG-LS Lossless |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.81|JPEG-LS Lossy (Near-Lossless) Image Compression |[pylibjpeg-libjpeg][1] | |1.2.840.10008.1.2.4.90|JPEG 2000 Image Compression (Lossless Only) |[pylibjpeg-openjpeg][4]| |1.2.840.10008.1.2.4.91|JPEG 2000 Image Compression |[pylibjpeg-openjpeg][4]| |1.2.840.10008.1.2.5 |RLE Lossless |[pylibjpeg-rle][5] | If you're not sure what the dataset's *Transfer Syntax UID* is, it can be determined with: ```python >>> from pydicom import dcmread >>> ds = dcmread('path/to/dicom_file') >>> ds.file_meta.TransferSyntaxUID.name ``` [1]: https://github.com/pydicom/pylibjpeg-libjpeg [2]: https://github.com/thorfdbg/libjpeg [3]: https://github.com/pydicom/pylibjpeg-openjpeg [4]: https://github.com/uclouvain/openjpeg [5]: https://github.com/pydicom/pylibjpeg-rle ### Usage #### Decoding ##### With pydicom Assuming you have *pydicom* v2.1+ and suitable plugins installed: ```python from pydicom import dcmread from pydicom.data import get_testdata_file # With the pylibjpeg-libjpeg plugin ds = dcmread(get_testdata_file('JPEG-LL.dcm')) jpg_arr = ds.pixel_array # With the pylibjpeg-openjpeg plugin ds = dcmread(get_testdata_file('JPEG2000.dcm')) j2k_arr = ds.pixel_array # With the pylibjpeg-rle plugin and pydicom v2.2+ ds = dcmread(get_testdata_file('OBXXXX1A_rle.dcm')) # pydicom defaults to the numpy handler for RLE so need # to explicitly specify the use of pylibjpeg ds.decompress("pylibjpeg") rle_arr = ds.pixel_array ``` For datasets with multiple frames you can reduce your memory usage by processing each frame separately using the ``generate_frames()`` generator function: ```python from pydicom import dcmread from pydicom.data import get_testdata_file from pydicom.pixel_data_handlers.pylibjpeg_handler import generate_frames ds = dcmread(get_testdata_file('color3d_jpeg_baseline.dcm')) frames = generate_frames(ds) arr = next(frames) ``` ##### Standalone JPEG decoding You can also just use *pylibjpeg* to decode JPEG images to a [numpy ndarray](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.html), provided you have a suitable plugin installed: ```python from pylibjpeg import decode # Can decode using the path to a JPG file as str or path-like arr = decode('filename.jpg') # Or a file-like... with open('filename.jpg', 'rb') as f: arr = decode(f) # Or bytes... with open('filename.jpg', 'rb') as f: arr = decode(f.read()) ``` #### Encoding ##### With pydicom Assuming you have *pydicom* v2.2+ and suitable plugins installed: ```python from pydicom import dcmread from pydicom.data import get_testdata_file from pydicom.uid import RLELossless ds = dcmread(get_testdata_file("CT_small.dcm")) # Encode in-place using RLE Lossless and update the dataset # Updates the Pixel Data, Transfer Syntax UID and Planar Configuration ds.compress(uid) # Save compressed ds.save_as("CT_small_rle.dcm") ``` %prep %autosetup -n pylibjpeg-1.4.0 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-pylibjpeg -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Sun Apr 23 2023 Python_Bot - 1.4.0-1 - Package Spec generated