Cocoon
  1. Cocoon
  2. COCOON-2133

Addition of "allow-enlarge" parameter to ImageOp resize operation

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Blocks: ImageOp
    • Labels:
      None
    • Urgency:
      Normal
    • Other Info:
      Patch available
    • Affects version (Component):
      Blocks: ImageOp - 1.0.0-M1-SNAPSHOT
    • Fix version (Component):
      Blocks: ImageOp - 1.0.0-M1-SNAPSHOT

      Description

      The addition of an "allow-enlarge" parameter to the resize operation allows the user to control whether an image should be enlarged by the operation.

      This new parameter is declared in the sitemap like so:

      <map:read type="imageop" src="image.jpg">
      <map:parameter name="prefix-preserve-ratio" value="true"/>
      <map:parameter name="prefix-allow-enlarge" value="false"/>
      <map:parameter name="prefix-width" value="320"/>
      <map:parameter name="prefix-height" value="240"/>
      </map:read>
      1. ResizeOperation.patch
        3 kB
        Robin Wyles
      2. RevisedResizeOperationPatch.txt
        3 kB
        Robin Wyles
      3. cocoon-core-SitemapComponentTestCase-read-method.patch
        3 kB
        Grzegorz Kossakowski
      4. cocoon-imageop-impl-no-effects-test.patch
        16 kB
        Grzegorz Kossakowski
      5. cocoon-imageop-impl-resize-operation-and-test.patch
        11 kB
        Robin Wyles
      6. 4x2.jpg
        0.8 kB
        Robin Wyles

        Issue Links

          Activity

          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Closed Closed
          117d 11h 41m 1 Grzegorz Kossakowski 09/Jan/08 21:24
          Tricia Jenkins made changes -
          Link This issue is cloned as COCOON-2290 [ COCOON-2290 ]
          Hide
          Alfred Nathaniel added a comment -
          Show
          Alfred Nathaniel added a comment - Backported to 2.1: http://svn.apache.org/viewvc?rev=674121&view=rev
          Grzegorz Kossakowski made changes -
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Closed [ 6 ]
          Hide
          Grzegorz Kossakowski added a comment -
          Patch comitted in r610567.

          Thanks Robin for providing test-case! The fact that your improvement is covered by tests moved your patch to the top of my personal patches-to-review-and-apply queue. :)
          Show
          Grzegorz Kossakowski added a comment - Patch comitted in r610567. Thanks Robin for providing test-case! The fact that your improvement is covered by tests moved your patch to the top of my personal patches-to-review-and-apply queue. :)
          Grzegorz Kossakowski made changes -
          Affects Version/s 2.1.11 [ 12312231 ]
          Fix version (Component) Parent values: Blocks: ImageOp(10336). Level 1 values: 1.0.0-M1-SNAPSHOT(10337).
          Affects version (Component) Parent values: Blocks: ImageOp(10334). Level 1 values: 1.0.0-M1-SNAPSHOT(10335).
          Affects Version/s 2.2-dev (Current SVN) [ 12310611 ]
          Grzegorz Kossakowski made changes -
          Assignee Grzegorz Kossakowski [ grek ]
          Robin Wyles made changes -
          Attachment cocoon-imageop-impl-resize-operation-and-test.patch [ 12372448 ]
          Attachment 4x2.jpg [ 12372449 ]
          Hide
          Robin Wyles added a comment -
          Grzegorz, thanks for your test case patches!

          Attached is patch for "allow-enlarge" parameter along with a suitable test case.

          Writing the tests I uncovered some strange behavior with allow-enlarge parameter when used with preserve-ratio. It seems that before my patches the ResizeOperation would fail to enlarge an image at all when preserve-ratio was set to true and only one dimension was supplied. This final patch fixes this issue, using allow-enlarge parameter to control first whether image should be resized and then preserve-ratio to determine final size.

          I also include my test image separately as well - for me at least images often seem to corrupt when supplied as part of a patch.
          Show
          Robin Wyles added a comment - Grzegorz, thanks for your test case patches! Attached is patch for "allow-enlarge" parameter along with a suitable test case. Writing the tests I uncovered some strange behavior with allow-enlarge parameter when used with preserve-ratio. It seems that before my patches the ResizeOperation would fail to enlarge an image at all when preserve-ratio was set to true and only one dimension was supplied. This final patch fixes this issue, using allow-enlarge parameter to control first whether image should be resized and then preserve-ratio to determine final size. I also include my test image separately as well - for me at least images often seem to corrupt when supplied as part of a patch.
          Grzegorz Kossakowski made changes -
          Hide
          Grzegorz Kossakowski added a comment -
          Here comes a patch adding very simple test for ImageOp reader.

          I have not given both patches too much testing but I hope you will find it helpful.
          Show
          Grzegorz Kossakowski added a comment - Here comes a patch adding very simple test for ImageOp reader. I have not given both patches too much testing but I hope you will find it helpful.
          Grzegorz Kossakowski made changes -
          Hide
          Grzegorz Kossakowski added a comment -
          Having some spare time while waiting for a bus I opened my laptop and created this patch. It adds missing read() method to be used for testing Readers.
          Show
          Grzegorz Kossakowski added a comment - Having some spare time while waiting for a bus I opened my laptop and created this patch. It adds missing read() method to be used for testing Readers.
          Robin Wyles made changes -
          Attachment RevisedResizeOperationPatch.txt [ 12372397 ]
          Hide
          Robin Wyles added a comment -
          Revised patch that fixes a bug with the previous patch where scaling with allowEnlarge property would be ignored when only one dimension needs to be reduced in size.
          Show
          Robin Wyles added a comment - Revised patch that fixes a bug with the previous patch where scaling with allowEnlarge property would be ignored when only one dimension needs to be reduced in size.
          Hide
          Robin Wyles added a comment -
          I'd be happy to provide a test-case but I can't see how to set one up to test a Reader. Looking at SitemapComponentTestCase I don't see a corresponding "read" method and I can't find any test-cases for other readers in any other blocks. If you can let me know how I might implement this test-case then I'll write it.

          In the meantime I attach a revised patch that fixes a bug with the previous patch where scaling with allowEnlarge property would be ignored when only one dimension needs to be reduced in size.
          Show
          Robin Wyles added a comment - I'd be happy to provide a test-case but I can't see how to set one up to test a Reader. Looking at SitemapComponentTestCase I don't see a corresponding "read" method and I can't find any test-cases for other readers in any other blocks. If you can let me know how I might implement this test-case then I'll write it. In the meantime I attach a revised patch that fixes a bug with the previous patch where scaling with allowEnlarge property would be ignored when only one dimension needs to be reduced in size.
          Grzegorz Kossakowski made changes -
          Fix Version/s 2.1.11 [ 12312231 ]
          Fix Version/s 2.2-dev (Current SVN) [ 12310611 ]
          Hide
          Grzegorz Kossakowski added a comment -
          Thanks Robin for providing a patch.

          Before it can be applied I would like to see it covered by test-case. Could also attach a test for allow-enlarge parameter?
          Show
          Grzegorz Kossakowski added a comment - Thanks Robin for providing a patch. Before it can be applied I would like to see it covered by test-case. Could also attach a test for allow-enlarge parameter?
          Robin Wyles made changes -
          Field Original Value New Value
          Attachment ResizeOperation.patch [ 12365833 ]
          Hide
          Robin Wyles added a comment -
          Patch to add "allow-enlarge" parameter to imageop resize operation.
          Show
          Robin Wyles added a comment - Patch to add "allow-enlarge" parameter to imageop resize operation.
          Robin Wyles created issue -

            People

            • Assignee:
              Grzegorz Kossakowski
              Reporter:
              Robin Wyles
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development