diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index d4f0eb66a..175e7dd1c 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -31,7 +31,7 @@ jobs: py=$(echo ${{ matrix.python-version }} | tr -d .) echo "py=$py" >> $GITHUB_OUTPUT shell: bash - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -49,8 +49,10 @@ jobs: - test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/setup-python@v4 + with: + python-version: '3.9' - name: Build package run: | python -mpip install wheel diff --git a/setup.py b/setup.py index de59c856e..233f5be07 100644 --- a/setup.py +++ b/setup.py @@ -218,13 +218,13 @@ def read(fname): entry_points={ 'console_scripts': ['omero=omero.main:main'], }, - python_requires='>=3', + python_requires='>=3.8', install_requires=[ 'urllib3<2', 'appdirs', 'future', 'numpy', - 'Pillow', + 'Pillow>=10.0.0', 'PyYAML', 'zeroc-ice>=3.6.5,<3.7', 'pywin32; platform_system=="Windows"', diff --git a/src/omero/gateway/__init__.py b/src/omero/gateway/__init__.py index cc3e48aea..229af9d59 100644 --- a/src/omero/gateway/__init__.py +++ b/src/omero/gateway/__init__.py @@ -9478,7 +9478,8 @@ def _wordwrap(self, width, text, font): p1 = 0 p2 = 1 while (p2 <= len(tokens) and - font.getsize(' '.join(tokens[p1:p2]))[0] < width): + (font.getbbox(' '.join(tokens[p1:p2]))[2] - + font.getbbox(' '.join(tokens[p1:p2]))[0]) < width): p2 += 1 rv.append(' '.join(tokens[p1:p2-1])) tokens = tokens[p2-1:] @@ -9582,7 +9583,7 @@ def createMovie(self, outpath, zstart, zend, tstart, tend, opts=None): line = line.decode('utf8').encode('iso8859-1') wwline = self._wordwrap(w, line, font) for j, line in enumerate(wwline): - tsize = font.getsize(line) + tsize = font.getbbox(line)[2:] draw = ImageDraw.Draw(slide) if i == 0: y = 10+j*tsize[1] diff --git a/src/omero/util/figureUtil.py b/src/omero/util/figureUtil.py index 48f6e8800..9c95f08c4 100644 --- a/src/omero/util/figureUtil.py +++ b/src/omero/util/figureUtil.py @@ -281,9 +281,12 @@ def getVerticalLabels(labels, font, textGap): maxWidth = 0 height = 0 - textHeight = font.getsize("testq")[1] + box = font.getbbox("testq") + textHeight = box[3] - box[1] for label in labels: - maxWidth = max(maxWidth, font.getsize(label)[0]) + box = font.getbbox(label) + width = box[2] - box[0] + maxWidth = max(maxWidth, width) if height > 0: height += textGap height += textHeight @@ -292,7 +295,9 @@ def getVerticalLabels(labels, font, textGap): textdraw = ImageDraw.Draw(textCanvas) py = 0 for label in labels: - indent = old_div((maxWidth - font.getsize(label)[0]), 2) + box = font.getbbox(label) + width = box[2] - box[0] + indent = old_div((maxWidth - width), 2) textdraw.text((indent, py), label, font=font, fill=(0, 0, 0)) py += textHeight + textGap return textCanvas.rotate(90) diff --git a/src/omero/util/imageUtil.py b/src/omero/util/imageUtil.py index 2369153f6..3aa32a46c 100644 --- a/src/omero/util/imageUtil.py +++ b/src/omero/util/imageUtil.py @@ -177,10 +177,14 @@ def paintThumbnailGrid(thumbnailStore, length, spacing, pixelIds, colCount, fontsize = old_div(length, 10) + 5 font = getFont(fontsize) if leftLabel: - textWidth, textHeight = font.getsize(leftLabel) + box = font.getbbox(leftLabel) + textWidth = box[2] - box[0] + textHeight = box[3] - box[1] leftSpace = spacing + textHeight + spacing if topLabel: - textWidth, textHeight = font.getsize(topLabel) + box = font.getbbox(topLabel) + textWidth = box[2] - box[0] + textHeight = box[3] - box[1] topSpace = spacing + textHeight + spacing minWidth = leftSpace + textWidth + spacing @@ -200,7 +204,8 @@ def paintThumbnailGrid(thumbnailStore, length, spacing, pixelIds, colCount, labelSize = (labelCanvasWidth, labelCanvasHeight) textCanvas = Image.new(mode, labelSize, bg) draw = ImageDraw.Draw(textCanvas) - textWidth = font.getsize(leftLabel)[0] + box = font.getbbox(leftLabel) + textWidth = box[2] - box[0] textX = old_div((labelCanvasWidth - textWidth), 2) draw.text((textX, spacing), leftLabel, font=font, fill=textColour) verticalCanvas = textCanvas.rotate(90) diff --git a/src/omero/util/image_utils.py b/src/omero/util/image_utils.py index e91247947..a92816d6b 100644 --- a/src/omero/util/image_utils.py +++ b/src/omero/util/image_utils.py @@ -122,10 +122,14 @@ def paint_thumbnail_grid(thumbnail_store, length, spacing, pixel_ids, fontsize = old_div(length, 10) + 5 font = get_font(fontsize) if left_label: - text_width, text_height = font.getsize(left_label) + box = font.getbbox(leftLabel) + text_width = box[2] - box[0] + text_height = box[3] - box[1] left_space = spacing + text_height + spacing if top_label: - text_width, text_height = font.getsize(top_label) + box = font.getbbox(top_label) + text_width = box[2] - box[0] + text_height = box[3] - box[1] top_space = spacing + text_height + spacing min_width = left_space + text_width + spacing @@ -146,7 +150,8 @@ def paint_thumbnail_grid(thumbnail_store, length, spacing, pixel_ids, label_size = (label_canvas_width, label_canvas_height) text_canvas = Image.new(mode, label_size, bg) draw = ImageDraw.Draw(text_canvas) - text_width = font.getsize(left_label)[0] + box = font.getbbox(leftLabel) + text_width = box[2] - box[0] text_x = old_div((label_canvas_width - text_width), 2) draw.text((text_x, spacing), left_label, font=font, fill=text_color) vertical_canvas = text_canvas.rotate(90)