Metadata-Version: 2.4
Name: collective.autoscaling
Version: 2.0.0
Summary: Automatic scaling of (too large) images in Plone sites
Author-email: Laurent Lasudry <laurent.lasudry@affinitic.be>
License-Expression: GPL-2.0-only
Project-URL: PyPI, https://pypi.org/project/collective.autoscaling
Project-URL: Source, https://github.com/collective/collective.autoscaling
Project-URL: Issues, https://github.com/collective/collective.autoscaling/issues
Project-URL: Changelog, https://github.com/collective/collective.autoscaling/blob/master/CHANGES.md
Keywords: Python,Plone
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Plone
Classifier: Framework :: Plone :: 6.1
Classifier: Framework :: Plone :: 6.2
Classifier: Framework :: Plone :: Addon
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.GPL
License-File: LICENSE.md
Requires-Dist: Pillow
Requires-Dist: Products.CMFPlone
Requires-Dist: plone.api
Requires-Dist: plone.base
Provides-Extra: test
Requires-Dist: plone.app.contenttypes; extra == "test"
Requires-Dist: plone.app.robotframework[debug]; extra == "test"
Requires-Dist: plone.app.testing; extra == "test"
Requires-Dist: plone.testing; extra == "test"
Requires-Dist: robotsuite; extra == "test"
Requires-Dist: zest.releaser[recommended]; extra == "test"
Requires-Dist: zestreleaser.towncrier; extra == "test"
Requires-Dist: zope.testrunner; extra == "test"
Dynamic: license-file

# collective.autoscaling

[![Tests](https://github.com/collective/collective.autoscaling/actions/workflows/test-matrix.yml/badge.svg)](https://github.com/collective/collective.autoscaling/actions/workflows/test-matrix.yml)
[![Meta](https://github.com/collective/collective.autoscaling/actions/workflows/meta.yml/badge.svg)](https://github.com/collective/collective.autoscaling/actions/workflows/meta.yml)

This package allows automatic scaling of too large images in Plone sites.
Images can be either Image content type or any Image field on content types.

This is totally transparent to the user (except if you choose to show message).

There is also a view (`@@resize-images`) that you can call to scale existing images (under the context of your choice), for example:

- http://localhost:8080/plone/@@resize-images
- http://localhost:8080/plone/folder/subfolder/@@resize-images


## Settings

- Enable automatic scaling (yes / no)
- Maximum height at which images will be automatically resized (in pixels)
- Maximum width at which images will be automatically resized (in pixels)
- JPEG quality
- Show information message to user when images have been resized (yes / no)


## Use case

1. You configure collective.autoscaling to have images with maximum size of height 800px / width 1200px.
2. One of your user uploads a really big image: height 2000px / width 4000px.
3. This image will be resized to height 600px / width 1200px (aspect ratio is of course preserved).


## Limitations

This add-on works only with Dexterity content types.

Version 2.x supports Plone 6.1 on Python 3.10 to 3.13, and Plone 6.2 on Python
3.10 to 3.14.
For Plone 4.3 to 6.0, use collective.autoscaling 1.x.


## Translations

This product has been translated into

- English
- French
- Norwegian
- Portuguese


## Installation

Add `collective.autoscaling` to the dependencies of your project
(`pyproject.toml`, or `requirements.txt` with the Plone constraints), install it,
restart Plone and activate the add-on in *Site Setup* > *Add-ons*.


## Development

Requires [uv](https://docs.astral.sh/uv/). This installs Plone 6.2.3 in `.venv`
(use `PLONE_VERSION=6.1.6 make install` for another version) and the prek git hook:

```shell
make install
make start          # Plone on http://localhost:8080 (admin / admin)
```

Create a Classic UI site from the browser, then activate collective.autoscaling.

### Tests

Tests run through tox, as the CI does. The robot scenarios run in headless
Chrome, which must be installed (Node.js too, for `rfbrowser init`):

```shell
make test                                   # Plone 6.2.3
uvx --with tox-uv tox -e py312-plone61      # one Plone / Python combination
make test-all                               # lint, every combination, dependencies
```

Integration tests only, without tox:

```shell
.venv/bin/zope-testrunner --test-path=src -s collective.autoscaling
```

### Lint

```shell
make check          # format then lint (pyupgrade, isort, black, zpretty, flake8...)
```

`.editorconfig`, `.flake8`, `.gitignore`, `.pre-commit-config.yaml`, `tox.ini`,
`.github/` and the tool sections of `pyproject.toml` are generated by
[plone.meta](https://github.com/plone/meta): change `.meta.toml`, then run
`uvx --from plone.meta config-package --no-commit --branch current .`.


## Contribute

- Issue Tracker: https://github.com/collective/collective.autoscaling/issues
- Source Code: https://github.com/collective/collective.autoscaling


## License

The project is licensed under the GPLv2.

# Contributors

- Laurent Lasudry, Original Author [Affinitic]
- Espen Moe-Nilssen
- Marc Lavallée

# Changelog

<!-- towncrier release notes start -->

## 2.0.0 (2026-11-18)


- Breaking: replace the `pkg_resources` namespace of `collective` with a
  PEP 420 native namespace. Support Plone 6.1 only on Python 3.10 to 3.13,
  and Plone 6.2 on Python 3.10 to 3.14. Use 1.x for Plone 4.3 to 6.0.
  [remdub]

- Import `IPloneSiteRoot`, `INonInstallable` and `get_installer` from
  `plone.base` instead of the aliases Plone 6.2 deprecates, and use
  `plone.testing.zope` in the test layers.
  [remdub]

- Include the CMFCore permissions in `configure.zcml`, so the package also
  loads when it is included before Plone (`zcml_package_includes`).
  [remdub]

- Run the robot scenarios on the Plone 6.2 classic UI.
  [remdub]

- Configure the package with plone.meta 2.12.0 (test matrix on Plone 6.2.3
  and 6.1), move its metadata to `pyproject.toml`, convert the documentation
  to Markdown and run the development environment on Plone 6.2.3 with uv
  instead of buildout.
  [remdub]

- Fix typos in french translations
  [remdub]


## 1.2 (2022-02-21)


- Fix resize-images view that was saving nothing because of CSRF protection
  [laulaz]

- Add support for Python 3 / Plone 6
  [marclava, laulaz]

- Add new JPEG Quality setting
  [marclava]

- Improve resizing code
  [marclava]

- Add uninstall profile
  [laulaz]


## 1.1.2 (2019-01-15)


- Handle special cases when we don't get a request at ObjectAddedEvent
  (example: when an object is added at Zope startup)
  [laulaz]

- Remove useless dependency on CMFDefault (#5)
  [laulaz]


## 1.1.1 (2016-07-28)


- Pin plone.api to avoid any errors (#2)
  [laulaz]

- Add Portuguese translation
  [laulaz]


## 1.1 (2016-04-13)


- Remove dependency on plone.app.imagecropping (#1)
  [laulaz]

- Translations cleanup
  [laulaz]


## 1.0 (2016-04-11)


- Initial release.
  [laulaz]
