The Coldfusion Open Source Forums
Home | ImageCFC | CFFM | BlogCFM | CFMBB | CFOpenMail / ImapCFC | CFOpenChat
Forums | Profile | Inbox | Members | Chat | Search | Login | RSS
Vivio Technologies Dedicated Hosting
New Topic Reply Subscription Options   Previous Page  Page: 1   Previous Page

Forums: ImageCFC Forum: Cropping centre
Created on: 07/03/07 {ts '2013-05-22 11:13:00'} Views: 2586 Replies: 2
Cropping centre
Posted Tuesday, July 3, 2007 at {ts '2013-05-22 11:13:00'}

Hi Rick,

First of all - great cfc - love it. Took me ages to find this type of thing.

I am trying a crop method and was wondering if it is possible to crop in the center/middle of a larger image instead of from the specific pixel measurement from the top left.

Regards

Jan Smile

RE: Cropping centre
Posted Tuesday, July 3, 2007 at {ts '2013-05-22 11:22:00'}

There is no specific method needed to do this, you just have to calculate the math up front.

For example... use the readImage() method to return an image object, then the getImageInfo() method to get its dimensions.

startx = int((originalWidth - desiredWidth) / 2);
starty = int((originalHeight - desiredHeight) / 2);

THEN call the crop image with those dimensions and pass in the image object instead of the file path.

Although it takes a few more lines of code, it shouldn't perform any slower since there's still only one file read and and one file write.. the rest of the stuff happens on the image object in memory

Rick

Rick Root
I'm not certified, but I have been told that I'm certifiable!

www
RE: Cropping centre
Posted Wednesday, July 25, 2007 at {ts '2013-05-22 06:47:00'}

sorry I didn't reply, but that is great - works well, I just had to remember to set the size before crop to be two pixels bigger cos then you get the exact centre!

New Topic Reply Subscription Options   Previous Page  Page: 1   Previous Page
Subscription Options
Subscription options are available after you log in.

There are 3 active user sessions right now.