Implement "cropToRatio"
Status: Abandoned
Brought to you by:
gasper_k
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.
Simple Implementation
Discussion thread: https://sourceforge.net/projects/wideimage/forums/forum/670462/topic/3842051/index/page/1
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