<cfset sizeToCrop= ImageGetHeight(myImage) - 350> <cfset ImageCrop(myImage, 0 , #sizeToCrop# , #ImageGetWidth(myImage)# , #ImageGetHeight(myImage)# )>
If you output the parameters, you can see your y
and height
values are off. Say the original image dimensions are 500px x 500px
. Right now you are starting the crop too low, (ie y=150px
) and using the original height instead of the desired height (ie 350px
).
// current code (wrong)
ImageCrop(myImage, 0 , 150 , 500 , 500 )
To grab the center of the image, you need to start cropping at y=75
(ie excess height / 2). Then use the desired height (ie 350px
), not the original:
// ImageCrop( img, x, y, width, height )
yPosition = (originalHeight - desiredHeight) / 2;
ImageCrop(myImage, 0, yPosition, originalWidth, desiredHeight );