GD_CROP
NAME
gd_crop - Crops a GD image.
SYNOPSIS
gd_crop(gdsrc:variable, gddst:variable, srcx:integer, srcy:integer, srcw:integer, srch:integer, dstx:integer,dsty:integer, transparent:"string", bgcolor:"string", truecolor:true|false);
DESCRIPTION
This function is used to crop a GD image.
gd_crop really creates a new image, so it returns the new GD structure. The old GD structure is still valid. gd_free must be called with this new GD structure.
PARAMETERS
- srcx,srcy
- Initial coordinate. By default, it is (0,0).
- srcw,srch
- Width and Height. By default, it is width and height of image.
- dstx,dsty
- Where to put the image, usually (0,0).
- dstw,dsth
- If a destimage image is created, the Width and Height of the new image. By default it's defined as srch-srcy, srcw-srcx;
- gdsrc
- Source image to crop. The variable must hold a returned value from gd_new.
- gddst
- Destination image where the source image will be put. If this is not specified, a new image will be created to receive the crop image.
- truecolor
- truecolor, tells new() to create a truecolor GD::Image object. Truecolor images have 24 bits of color data (eight bits each in the red, green and blue channels respectively), allowing for precise photograph-quality color usage. If not specified, the image will use an 8-bit palette for compatibility with older versions of libgd.
- transparent
- Specifies transparent color. Transparent color can be specify as bgcolor to use the backgound color. A color is specified as "#XXXXX" or as "255,255,255". Note that JPEG images do not support transparency, so this setting has no effect when writing JPEG images.
- bgcolor
- Specifies background color. A color is specified as "#XXXXX" or as "255,255,255".
RETURN
- A pointer to the new GD structure. Will be used in other functions.
MODULES
To use this module, you must specify the following in /usr/local/website/site.conf:
Module gd {
Library : "/usr/local/lib/libsngd.so"
Init : "sngd_init"
}
EXAMPLES
res=<{
%include "/includes/gd.sn";
remove("/html/images/crop1.jpg");
remove("/html/images/crop2.jpg");
remove("/html/images/crop3.jpg");
imsrc=gd_new(filename:"/html/images/20130708-1944-londres.jpg",truecolor:true);
imdst=gd_new(width:1000,height:1000,bgcolor:Blue,truecolor:true);
gd_write(gd:imdst,format:"jpg",filename:"/html/images/crop3.jpg");
gd_crop(gdsrc:imsrc, gddst:imdst,srcx:400,srcy:400,srcw:800,srch:800,dstx:50,dsty:50);
gd_write(gd:imsrc,format:"jpg",filename:"/html/images/crop1.jpg");
gd_write(gd:imdst,format:"jpg",filename:"/html/images/crop2.jpg",quality:100);
gd_free(imsrc);
gd_free(imdst);
-e "/html/images/crop1.jpg"; -e "/html/images/crop2.jpg"; }>.), q(res=truetrue.),{asm=>"-a"});
SEE ALSO
AUTHOR
Written by Pierre Laplante and Caroline Laplante, <laplante@sednove.com>
MODIFICATIONS
1.0 2014-09-09 21:24:14 laplante@sednove.com
Edit