Menu

#44 Implement "cropToRatio"

future
open
4
2010-09-13
2010-09-07
No

CropToRatio basically allows to quickly crop and image to respect a specific aspect ratio. It is extremely useful in situations when you have to create a fixed size thumbnail.

Attached is a simple implementation. You may use that implementation if you wish. Just include my name in the file.

Discussion

  • Andrew Moore

    Andrew Moore - 2010-09-07

    Simple Implementation

     
  • Andrew Moore

    Andrew Moore - 2010-09-07
    • assigned_to: nobody --> gasper_k
     
  • Gasper Kozak

    Gasper Kozak - 2010-09-13
    • milestone: --> future
    • priority: 5 --> 4
     
  • Gasper Kozak

    Gasper Kozak - 2010-10-25

    Hi Andrew,

    I'm implementing this feature and I have a question about.

    If I understand it correctly, it produces an image with the specified ratio; for example cropToRatio('center', 'center', 1, 1) produces an image with 1:1 ratio (cut from the middle), whereas cropToRatio('center', 'center', 1, 2) produces an image that is twice the height. It works the same with cropToRatio('center', 'center', 0.5, 1). I'm wondering if there is some specific reason why you normalize the ratios in the beginning of the operation via WideImage_Coordinate::fix() method? Since these ratios are just numbers, there's no sense in supporting smart coordinates, for eg. cropToRatio('center', 'center', '50%', 'right'), or is it? If my assumption is correct, then the call to fix() is unnecessary and I'll remove it.

    Best regards,
    gasper

     

Log in to post a comment.

MongoDB Logo MongoDB