Ticket #10174 (reopened PLIP)

Opened 4 years ago

Last modified 6 months ago

Image cropping for Plone

Reported by: hpeteragitator Owned by:
Priority: minor Milestone: Future
Component: Backend (Python) Version: 4.1
Keywords: image, cropping Cc: saily, vangheem

Description

Proposer: Peter Holzer hpeteragitator
Seconder: Jens Klein jensens


Motivation

plone.app.imaging allows to configure image scales,
why not allow cropped image scales too?

Assumptions

there are already some products that allow image-cropping
since it is a common task in a portal, make it a default feature

imho these products allow that already
collective.croppingimagefield
Products.croppingimage
Products.RichImage
archetypes.clippingimage

Proposal & Implementation

evaluation of the cropping mechanism that are already in use
and since the default image scaling mechanism is only downscaling,
a simple approach like archetypes.clippingimage should be enough.

i would see that feature as a further option checkbox/field
to the existing configuration in plone_control_panel/generic-setup

Deliverables

  • Unit tests
  • Localization
  • Documentation

Risks

none, if it's not the default?

Participants

me, hpeteragitator would be in testing/documentation
jensens, code
witsch

Progress

existing scaling methods

Change History

comment:1 Changed 4 years ago by dunny

Could this also support cropping from different parts of the original image?

Cropping from the centre is the usual behaviour. However there are some contexts where cropping from the top or the bottom of the image works out better. For example if the content is largely images of groups of people then cropping a square from the top (rather than the centre) of a portrait oriented image usually works better.

Perhaps just ensure that there is a clean way for an integrator to override the cropping algorithm with their own?

comment:2 Changed 4 years ago by sergey_v

I think that by 'cropping' you mean just a different algorithm for thumbnail generation which ensures that the resulting image is always of the same size (i.e. it fits the narrow side of the image to match the thumb's size, potentially cropping out parts of the image; as opposed to the current algorithm which fits the long side of the image, potentially making the narrow side shorter than the thumbnail dimensions).

A more flexible cropping may require more settings which would allow you to downscale an image first and then crop it... so it may look like

Scale to: [ 100x100] Fit: [(narrow side - wide side)] Crop to: [ 64x64] From: [(topleft-top-...-center-...-bottom)]

Potential use-cases for that:

  • portrait images mentioned by dunny
  • screenshots of web pages where you want to display only the top-left corner of the image
  • images with borders/margins which you don't want to be in the thumbnails

While we're at it, there are a few more things which may be very useful:

  • watermarks
  • grayscale/sepia/blur/sharpen/drop shadows/fancy frames/etc.

It would be super-cool to implement some sort of a pluggable image-transform 'plugins' so product authors could easily implement their own filters:

def myFancyThumbnail(pil_image_object):

result = do_somtheing_interesting(pil_image_object) return result

from plone.app.imaging import registerTransformPlugin registerTransformPlugin('Fancy Thumbnail', myFancyThumbnail)

and then you can choose 'Fancy Thumbnail' as one of the transforms for a given image scale in the control panel.

PIL is a very powerful and easy to work with library, we're currently using 0.1% of its features - mostly because it's very difficult to plug your code into the existing framework... i know because I recently tried to implement image watermarking :)

comment:3 Changed 3 years ago by frisi

we've discussed this in a openspace session at ploneconf in bristol and are starting  http://dev.plone.org/plone/browser/plone.app.imaging/branches/bristol-transforms now

comment:4 Changed 3 years ago by rossp

  • Status changed from new to closed
  • Resolution set to wontfix

PLEASE READ THIS AND RE-OPEN VALID PLIPS!

As we launch the new PLIP process we'd like to see which PLIPs:

  • are still appropriate/needed
  • still have owners/proposers/champions
  • still have available implementers

If this PLIP should still be considered for future releases of Plone please do re-open this ticket and assign an appropriate milestone. If it should be considered for the next release of Plone, use the 4.2 milestone. Also be sure to update the PLIP description, requester, owner, etc. and include a comment detailing recent progress and new plans. We will use all these details in the new continuous PLIP process.

comment:5 Changed 22 months ago by adrianwhite

  • Status changed from closed to reopened
  • Keywords ploneimagecrop added; plone image crop removed
  • Resolution wontfix deleted

Could we please consider doing this PLIP? I would find cropping support extremely useful.

comment:6 Changed 22 months ago by adrianwhite

I'm not sure why re-opening this PLIP changed the keywords to have no spaces. I seem unable to add the spaces back in.

comment:7 Changed 22 months ago by kleist

  • Status changed from reopened to confirmed
  • Keywords image, cropping added; ploneimagecrop removed
  • Version set to 4.1
  • Component changed from Unknown to Backend (Python)

Trac does that now a days, I'm afraid. A comma must be used as separator.

Please note the following in comment 4: "include a comment detailing recent progress and new plans".

comment:8 Changed 20 months ago by saily

  • Cc saily added

afaik you are already able to crop images with plone.app.imaging using the direction attribute.

...
tag1 = obj.tag('image', width=128, height=128, direction="down")
tag2 = obj.tag('image', width=128, height=128, direction="keep")
...

we should check if it's possible to integrate some kind of editor to let users define which area to crop. A javascript library for this purpose could be Jcrop, see:  http://deepliquid.com/content/Jcrop.html

comment:9 Changed 19 months ago by eleddy

  • Status changed from confirmed to closed
  • Resolution set to wontfix

There are a couple addons that do this already so the FWT discussed and we think this should be an add-on first, and in addition be compatible with dexterity before pliping into core. There are obviously some design decisions to be made here still and this is better done outside of the core we think. There is definitely a need to do this since none of the current addons work with dexterity.

comment:10 Changed 18 months ago by petschki

We've created an addon at the ploneconf2012 imagecropping sprint which aims to be THE solution for imagecropping in plone. it is available here:  https://github.com/collective/plone.app.imagecropping ... alpha release will come very soon on pypi

comment:11 Changed 14 months ago by vangheem

UI Team Review

I've also posted the review on the issue tracker but I'll also copy the text here for people to see:  https://github.com/collective/plone.app.imagecropping/issues/9

  • Instead of providing a "Cropping" button, can we customize the image widget to include a link to "crop" the image. Then, it should be able to handle multi-image content types.
  • Are we hitting the correct use case here with our scale selection? Since plone already provides support for image scales, being able to crop, only to those scales seems prohibiting. The way I imagine people wanting to use this is for cropping parts of the image out or using a custom size that they'll reference the original image in a page or news item(and using a custom size is not possible right now).
  • All the image scales are actually the same aspect ratio so they end up not being very helpful--they're all just different sizes of the same aspect ratio. If we are going to provide a pre-set list of cropping sizes and ratios, I think we should provide often used ratios here like 4x6, 3x5, etc.
  • This functionality should probably merge with the "Transform" button.
  • I think your UI is mostly fine. It's good to keep something like this as simple as possible.
  • I'm not sure what the point of the delete button is. I think that can probably be removed.
  • The cancel button should probably be offset of the save button so there is less of a chance for accidental clicks.
  • A little more styling could help spiff up the UI a bit. Once the functionality gets to where we want it, we should have a designer touch it up a bit.

comment:12 Changed 14 months ago by vangheem

  • Cc vangheem added

comment:13 Changed 14 months ago by petschki

  • Summary changed from Image cropping for plone.app.imaging to Image cropping for Plone

Since the UI team is reviewing this addon, can we get this PLIP reopened? I think right now it's ab bit missleading if someone searches for a cropping solution in plone and finds a rejected ticket. Any suggestions?

comment:14 Changed 13 months ago by vangheem

  • Status changed from closed to reopened
  • Resolution wontfix deleted

Sure, but let's not ask for a review until it's ready then.

comment:15 Changed 10 months ago by esteele

  • Milestone changed from 4.x to 5.0

The Framework Team has decided to move on to Plone 5. Updating milestones accordingly.

comment:16 Changed 6 months ago by davisagli

  • Milestone changed from 5.0 to Future

Reassigning to Future milestone; this is out of scope for Plone 5.

Note: See TracTickets for help on using tickets.