Skip to content

Commit

Permalink
Merge pull request #57 from bodleian/dependabot/pip/pillow-10.0.1
Browse files Browse the repository at this point in the history
Bump pillow from 9.1.0 to 10.0.1
  • Loading branch information
mel-mason authored Oct 10, 2023
2 parents dc4364a + e7496a8 commit b697d84
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Installation

``pip install git+https://github.com/bodleian/image-processing.git``

- Tested on Python 3.8, but should work with most 3.x versions
- Mostly tested on Python 3.8, but should also work on newer 3.x versions

Dependencies
~~~~~~~~~~~~
Expand Down Expand Up @@ -92,7 +92,9 @@ To just use Kakadu directly through the wrapper:
Development and Testing
-----------------------

We run a subset of our unit tests on Python versions 3.7+ using Github Actions. Tests that require Kakadu are skipped, as we cannot access the proprietary Kakadu executables from a public repository. Any changes should be tested locally, with Kakadu installed, rather than relying on the CI testing alone. You can use requirements.txt to set up a Python virtual environment.
We run a subset of our unit tests on Python versions 3.8+ using Github Actions. Tests that require Kakadu are skipped, as we cannot access the proprietary Kakadu executables from a public repository. Any changes should be tested locally, with Kakadu installed, rather than relying on the CI testing alone. You can use requirements.txt to set up a Python virtual environment.

The tests compare directly against image files to check for regression. When updating dependencies like Pillow these test image files may sometimes no longer match, especially jpgs. The current set of test images were generated with Pillow 10.0.1, Exiftool 12.40, and Kakadu 8.2


.. inclusion-marker-intro-end
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
author = 'Mel Mason'

# The full version, including alpha/beta/rc tags
release = '1.10.0'
release = '1.11.0'


# -- General configuration ---------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions image_processing/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def convert_to_jpg(self, input_filepath, output_filepath, resize=None, quality=N
input_pil = input_pil.convert(mode="RGB")
if resize:
thumbnail_size = tuple(int(i * resize) for i in input_pil.size)
input_pil.thumbnail(thumbnail_size, Image.LANCZOS)
input_pil.thumbnail(thumbnail_size, Image.Resampling.LANCZOS)
if quality:
input_pil.save(output_filepath, "JPEG", quality=quality, icc_profile=icc_profile)
else:
Expand Down Expand Up @@ -137,7 +137,7 @@ def convert_icc_profile(self, image_filepath, output_filepath, icc_profile_filep

input_profile = ImageCms.getOpenProfile(io.BytesIO(input_icc_obj))
output_pil = ImageCms.profileToProfile(input_pil, input_profile, icc_profile_filepath,
renderingIntent=ImageCms.INTENT_PERCEPTUAL,
renderingIntent=ImageCms.Intent.PERCEPTUAL,
outputMode=new_colour_mode, inPlace=0)
output_pil.save(output_filepath)
self.copy_over_embedded_metadata(image_filepath, output_filepath)
6 changes: 3 additions & 3 deletions image_processing/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def check_image_suitable_for_jp2_conversion(image_filepath, require_icc_profile_

# As we rarely encounter RGBA files, and mostly ones without any alpha channel data, we just warn here
# the visually identical check should pick up any problems
logger.warn("You must double check the jp2 conversion is lossless. "
logger.warning("You must double check the jp2 conversion is lossless. "
"{0} is an RGBA image, and the resulting jp2 may convert back to an RGB tiff "
"if the alpha channel is unassociated".format(image_filepath))

Expand All @@ -207,10 +207,10 @@ def check_image_suitable_for_jp2_conversion(image_filepath, require_icc_profile_

icc = image_pil.info.get('icc_profile')
if icc is None:
logger.warn('No icc profile embedded in {0}'.format(image_filepath))
logger.warning('No icc profile embedded in {0}'.format(image_filepath))
if icc_needed:
raise exceptions.ValidationError('No icc profile embedded in {0}.'.format(image_filepath))

frames = len(list(ImageSequence.Iterator(image_pil)))
if frames > 1:
logger.warn('File has multiple layers: only the first one will be converted')
logger.warning('File has multiple layers: only the first one will be converted')
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
py==1.11.0
pytest==7.1.2
uuid==1.30
Pillow==9.1.0
Pillow==10.0.1
jpylyzer==2.0.1
Sphinx==5.0.2
sphinx-rtd-theme==1.0.0
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
long_description = f.read()

setup(name='image_processing',
version='1.10.0',
version='1.11.0',
description='Digital Bodleian image processing library',
url='http://github.com/bodleian/image-processing',
license="MIT",
Expand Down
Binary file modified tests/data/bilevel_tif_resized.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/bilevel_tif_resized_different_exiftool.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/bilevel_tif_xmp.jp2
Binary file not shown.
Binary file modified tests/data/greyscale_gamma_tif_resized.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/greyscale_gamma_tif_xmp.jp2
Binary file not shown.
Binary file modified tests/data/greyscale_without_profile_tif_resized.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/greyscale_without_profile_tif_xmp.jp2
Binary file not shown.
7 changes: 6 additions & 1 deletion tests/data/standard_adobe_tif.xmp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 10.10'>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 12.40'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
Expand Down Expand Up @@ -51,6 +51,11 @@
<photoshop:ICCProfile>Adobe RGB (1998)</photoshop:ICCProfile>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:prism='http://prismstandard.org/namespaces/basic/2.0/'>
<prism:pageCount>2</prism:pageCount>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
<tiff:BitsPerSample>
Expand Down
5 changes: 5 additions & 0 deletions tests/data/standard_adobe_tif_different_exiftool.xmp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<photoshop:ICCProfile>Adobe RGB (1998)</photoshop:ICCProfile>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:prism='http://prismstandard.org/namespaces/basic/2.0/'>
<prism:pageCount>2</prism:pageCount>
</rdf:Description>

<rdf:Description rdf:about=''
xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
<tiff:BitsPerSample>
Expand Down
Binary file modified tests/data/standard_adobe_tif_hq.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/standard_adobe_tif_resized.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/data/standard_adobe_tif_xmp.jp2
Binary file not shown.

0 comments on commit b697d84

Please sign in to comment.