Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install plone.app.imagecropping

How to install plone.app.imagecropping

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install plone.app.imagecropping
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
Windows (64-bit)
Mac OS X (10.5+)
Linux (32-bit)
0.1a2
0.1rc2Never BuiltWhy not?
0.1a2 Available View build log
0.1a1 Available View build log
Linux (64-bit)
0.1rc2 Available View build log
0.1a2 Available View build log
0.1a1 Available View build log
 
License
GPLv2
Lastest release
version 0.1rc2 on May 24th, 2013
https://travis-ci.org/collective/plone.app.imagecropping.png?branch=master

History

There has been a need for cropping for a long time and there are lots of addons around that have different ways to achieve this.

There is plip #10174 asking for adding image cropping to plone core which recently got rejected by the FWT. The cropping functionality should go into an addon first that also work for dexterity and can be pliped into core.

This package aims to be THE cropping solution for plone that just works TM.

Why do I need this?

Automatic cropping is already possible, plone.app.imaging does already handle this via the direction parameter:

<img tal:define="scales context/@@images"
     tal:replace="structure python: scales.tag('image',
                  width=1200, height=800, direction='down')"
     />

However it only crops from the top/center of the image, so in some ocasions this is not what you want.

plone.app.imagecropping allows you to select the cropping area manually for each available image scale using the JCrop editor

How it works

There is a view @@croppingeditor available for every content type implementing IImageCropping via an object action.

The Interface is implemented by default for ATImage and plone.app.contenttypes image.

The editor view shows at maximum three columns:

  • Image Fields column (only visible when more than one image field is available)
  • Image scales column (only visible when more than one scale is available)
  • Cropping editor column

The aspect ratio for the cropping area in JCrop editor is automatically set to the image scale selected by the user.

https://raw.github.com/collective/plone.app.imagecropping/master/docs/editor.png

The image stored for this scale gets replaced with the cropped and scaled version. This way you can access them as you're used to. For example:

<img tal:replace="structure context/@@images/image/mini" />

This also enables support for richtext editors such as TinyMCE to insert cropped scales into a textfield.

In TinyMCE it will be possible to access the cropping editor directly out of the image plugin right below the scale selection

Load editor as overlay

The editor can also be loaded as an overlay anywhere. Just place a link to the @@croppingeditor url of an image (<image_base_url>/@@croppingeditor) and add some javascript. For example:

(function($) {
    $(function() {
        $("a[href$='@@croppingeditor']").prepOverlay({
            subtype:'ajax',
            formselector:'#coords',
            closeselector:"input[name='form.button.Cancel']"
        })

        $(document).bind("formOverlayLoadSuccess", function() {
            imagecropping.init_editor();
        })
    })
})(jQuery);
Configuration

A Configlet is registered in Plone Site Setup. There you can adjust the maximum Size of the jCrop Editor Image (large_size) and the minimum selectable size of the cropped area (min_size).

You can also set those values in the profile of your (policy)product using p.a.registry mechanism (registry.xml):

<registry>
  <records interface="plone.app.imagecropping.browser.settings.ISettings">
      <value key="large_size">500:500</value>
      <value key="min_size">10:10</value>
  </records>
</registry>
Design decisions
  • make this package as minimally invasive as possible
    • therefore we store the cropped image immediately, so plone.app.imaging traverser doesn't need to care about cropping
    • users can access cropped images the same way as the access scales (so it works in richtext editors too)
  • support archetypes and dexterity content (XXX limitation for dexterity: this will only work for images in AttributeStorage)
  • a cropped image gets stored instead of the scaled image. if you want back the uncropped image scale you'll need to remove the cropped version in the editor
Possible extensions / changes for the future
  • allow to mark scales as auto-croppable in the plone.app.imaging controlpanel. this enables cropped scales w/o manually defining the cropping area but would require some changes in plone.app.imaging (extend traverser, change controlpanel)

Contributors

  • Peter Mathis (petschki)
  • Joscha Krutzki (joka)
  • Harald Frießnegger (fRiSi)
  • Martijn Zweistra (themask96)
  • Daniel Widerin (saily)
  • Wolfgang Thomas (pysailor)
  • Héctor Velarde (hvelarde)
Credits

The basic concept of plone.app.imagcropping has already been implemented in Yiorgis's branch of plone.app.imaging

Changelog

0.1rc2 (2013-05-03)
  • Include styles for authenticated users only. [saily]
  • Make tests work in Plone 4.1 [saily]
  • Rename acceptance to robot to align new plone.app.robotframework guidelines. [saily]
  • Pin plone.app.testing to make Plone 4.1 tests work. [saily]
  • Use correct dependency for plone.app.testing with extra [robot]. [saily]
  • Add cropping ui-tests using robotframework [saily]
  • Update bootstrap.py to work with zc.buildout 2.0 [saily]
  • Implemented #11 - Mark image scales as "croppable" [jensens]
  • Added tests for control panel and registry
  • Added Spanish and Brazilian Portuguese translations [hvelarde]
  • Small documentation update [saily]
0.1rc1 (2013-03-11)
  • add support for multiple image fields
  • refactored javascript includes so the editor can be loaded as overlay
  • fixed JS error when editor is invisible (ie editor is loaded in an overlay)
  • fixed edit/remove actions when editor is loaded as overlay
  • make editor view more convenient (disable columns)
  • update documentation [petschki]
0.1b1 (2013-03-03)
  • Made cropping work in dexterity-only sites [pysailor]
  • Add travis integration [saily]
0.1a2 (2012-11-10)
  • fix tests
  • add test setups for Plone 4.1-4.3
  • Products.CMFPlone dependency. Right now we only support Plone >= 4.1
  • make dexterity support optional [petschki]
0.1a1 (2012-11-05)
  • public alpha release [petschki]
  • Package created using templer [fRiSi]

Subscribe to package updates

Last updated May 24th, 2013

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.