Media_TCrop ( left ; top ; bottom ; right )
Media_TCrop crops images the next time you call Media_TApply. Cropping is applied to the source image before other transformations (like TRotate, TSkew, TScale).
Parameter | Description |
---|---|
left | horizontal coordinate of the top-left point of the cropping rectangle. |
top | vertical coordinate of the top-left point of the cropping rectangle. |
right | horizontal coordinate of the bottom-right point of the cropping rectangle. |
bottom | vertical coordinate of the bottom-right point of the cropping rectangle. |
The crop parameter values are rounded to the nearest pixel.
Increasing Image Size
In addition to the ability to crop an image to a smaller canvas size, Media_TCrop can also be used to increase the image canvas size. To do this, all you need to do is set the TCrop parameters outside the original image’s dimensions. For example, if you have an image that is 100 x 100 and you want to add 20 pixels of unused space all around the image, use Media_TCrop ( -20 ; -20 ; 120 ; 120 ).
Crop Enacted First
If you call Media_TCrop along with other transformation functions and then activate them all with the same call to Media_TApply, Media_TCrop is always applied first. This is important to be aware of since it can affect the results of other transformation functions.
Activated by Media_TApply.
Returns
Empty string.
Examples
To crop an image down to 100 x 100 pixels that starts at an upper left point of 45, 35:
Set Field [ MyTable::Response; Media_TClear ]
Set Field [ MyTable::Response;
Media_TCrop ( 45; 35; 135; 145 ) ]
Set Field [ MyTable::Response; Media_TRotate ( 90 ) ]
Set Field [ MyTable::Picture Result;
Media_TApply ( MyTable::Picture 1 ) ]
To crop an image based on the values in four fields named “Crop Left”, “Crop Top”, “Crop Bottom”, and “Crop Right”:
Set Field [ MyTable::Response; Media_TClear ]
Set Field [ MyTable::Response;
Media_TCrop ( MyTable::Crop Left ;
MyTable::Crop Top ;
MyTable::Crop Bottom ;
MyTable::Crop Right ) ]
Set Field [ MyTable::Picture Result;
Media_TApply ( MyTable::Picture 1 ) ]
To increase the image canvas size by adding 150 pixels around a 350 x 450 pixel image:
Set Field [ MyTable::Response; Media_TClear ]
Set Field [ MyTable::Response;
Media_TCrop ( -150 ;
-150 ;
600 ;
500 ) ]
Set Field [ MyTable::Picture Result;
Media_TApply ( MyTable::Picture 1 ) ]