Aller au contenu principal

gd

Functions for GD.

GD

NAME

gd - Functions for GD.

SYNOPSIS

gd_new gd_free gd_write gd_get_size gd_get_pixel gd_resize gd_crop

DESCRIPTION

These functions implement GD library within sncode.

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/print.jpg");
        im=gd_new(width:1000,height:1000,bgcolor:Gray,truecolor:true);
        red = gd_get_color(gd:im, color:Red);
        cyan = gd_get_color(gd:im, color:Cyan);
        white = gd_get_color(gd:im, color:White);
        gd_ellipse(gd:im, cx:500,cy:500, width:100, color:Blue, height:100);
        gd_write(gd:im,format:"jpg",filename:"/html/images/print.jpg",quality:100);
        }>.
res=<{
        %include "/includes/gd.sn";
        remove("/html/images/print.jpg");
        im=gd_new(width:1000,height:1000,bgcolor:Gray,truecolor:true);
        red = gd_get_color(gd:im, color:Red);
        cyan = gd_get_color(gd:im, color:Cyan);
        white = gd_get_color(gd:im, color:White);
        gd_arc(gd:im, cx:500,cy:500, width:100, color:Blue, height:100, start_angle:0, end_angle:180);
        gd_arc(gd:im, cx:700,cy:700, width:100, color:Blue, height:100, start_angle:0, end_angle:180, filled:true, gdChord:true);
        gd_write(gd:im,format:"jpg",filename:"/html/images/print.jpg",quality:100);
        }>
res=<{
        %include "/includes/gd.sn";
        remove("/html/images/print.jpg");
        im=gd_new(width:1000,height:1000,bgcolor:Gray,truecolor:true);
        red = gd_get_color(gd:im, color:Red);
        cyan = gd_get_color(gd:im, color:Cyan);
        white = gd_get_color(gd:im, color:White);
        gd_polygon(gd:im, polygon:[ [10,10], [10, 500], [500, 500], [500, 10]], color:Yellow, thickness:2,filled:true);
        gd_polygon(gd:im, polygon:[ [40,40], [200,259], [332, 644], [500, 10], [700,700]], color:Red, thickness:1,closed:false);
        gd_write(gd:im,format:"jpg",filename:"/html/images/print.jpg",quality:100);
        }>
res=<{
        %include "/includes/gd.sn";
        remove("/html/images/print.jpg");
        im=gd_new(width:1000,height:1000,bgcolor:Gray,truecolor:true);
        red = gd_get_color(gd:im, color:Red);
        cyan = gd_get_color(gd:im, color:Cyan);
        white = gd_get_color(gd:im, color:White);
        cyan=5;
        a = [1,2,3,cyan,red,null];
        gd_line(gd:im, x1:500, y1:000, x2:500,y2:1000, thickness:20, style:[1,2,3,cyan,red,null],coloridx:red);
        gd_write(gd:im,format:"jpg",filename:"/html/images/print.jpg",quality:100);
        }>.
res=<{
        %include "/includes/gd.sn";
        remove("/html/images/print.jpg");
        im=gd_new(width:1000,height:1000,bgcolor:Gray,truecolor:true);
        coral = gd_get_color(gd:im, color:Coral);
        cyan = gd_get_color(gd:im, color:Cyan);
        white = gd_get_color(gd:im, color:White);
        gd_line(gd:im, x1:500, y1:500, x2:500,y2:300, thickness:20, style:[coral,cyan,null,color,null,white],coloridx:white);
        gd_line(gd:im, x1:600, y1:600, x2:600,y2:0, thickness:20, style:[white,null],coloridx:white);
        gd_line(gd:im, x1:614, y1:600, x2:614,y2:0, thickness:20, coloridx:white);
        color = gd_get_color(gd:im, color:Yellow);
        for(i=0;i<1000;++i)
                gd_set_pixel(gd:im, x:i, y:i, coloridx: color);
        endfor
        void gd_print(gd:im, x:100, y:100, coloridx:color, str:"Version: 1", size:24);
        gd_line(gd:im, x1:-100, y1:-100, x2:200,y2:900, color:White);
        gd_line(gd:im, x1:500, y1:500, x2:300,y2:300, style:[coral,cyan,null,color,null,white]);
        gd_write(gd:im,format:"jpg",filename:"/html/images/print.jpg",quality:100);
        gd_free(im);
        -e "/html/images/print.jpg"; }>.
res=<{
        %include "/includes/gd.sn";
        remove("/html/images/print.jpg");
        im=gd_new(width:1000,height:1000,bgcolor:Blue,truecolor:true);
        gd_print(str:"pierre en été",gd:im,color:White,font:"/ttf/arial.ttf",x:100,y:100,size:24);
        gd_print(str:"pierre en été",gd:im,color:Yellow,font:"/ttf/bignoodle.ttf",x:100,y:200,size:24);
        gd_print(str:"pierre en été",gd:im,color:Green,font:"/ttf/bignoodle.ttf",x:100,y:300,size:24, angle:45);
        gd_print(str:"pierre en été\net en hiver",gd:im,color:Red,font:"/ttf/bignoodle.ttf",x:100,y:400,size:24, angle:5,linespacing:2);
        gd_print(str:printf("%d", 123gd:im,color:White,font:"/ttf/arial.ttf",x:100,y:600,size:24);
        gd_write(gd:im,format:"jpg",filename:"/html/images/print.jpg",quality:100);
        gd_free(im);
        -e "/html/images/print.jpg"; }>.
res=<{
        %include "/includes/gd.sn";
        remove("/html/images/rot1.jpg");
        remove("/html/images/rot2.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_merge(gdsrc:imsrc, gddst:imdst,srcx:400,srcy:400,srcw:800,srch:800,dstx:50,dsty:50,pourc:45,gray:true);
        gd_write(gd:imsrc,format:"jpg",filename:"/html/images/rot1.jpg");
        gd_write(gd:imdst,format:"jpg",filename:"/html/images/rot2.jpg",quality:100);
        gd_free(imsrc);
        gd_free(imdst);
        -e "/html/images/rot1.jpg"; -e "/html/images/rot2.jpg"; }>.
res=<{
        %include "/includes/gd.sn";
        remove("/html/images/rot1.jpg");
        remove("/html/images/rot2.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_rotate(gdsrc:imsrc, gddst:imdst,srcx:400,srcy:400,srcw:800,srch:800,dstx:50,dsty:50,angle:45);
        gd_write(gd:imsrc,format:"jpg",filename:"/html/images/rot1.jpg");
        gd_write(gd:imdst,format:"jpg",filename:"/html/images/rot2.jpg",quality:100);
        gd_free(imsrc);
        gd_free(imdst);
        -e "/html/images/rot1.jpg"; -e "/html/images/rot2.jpg"; }>.
res=<{
        remove("/html/images/resize1.gif");
        remove("/html/images/resize2.gif");
        remove("/html/images/resize3.gif");
        im=gd_new(width:1000,height:1000,bgcolor:"#0000f0",truecolor:true);
        im2=gd_new(filename:"/html/images/20130708-1944-londres.jpg",truecolor:true);
        im3=gd_new(width:1000,height:1000,bgcolor:"#0000f0",truecolor:true);
        gd_resize(gdsrc:im2,gddst:im,dstx:50,dsty:50, dstw:800, dsth:800);
        gd_resampled(gdsrc:im2,gddst:im3,dstx:50,dsty:50, dstw:800, dsth:800);
        gd_write(gd:im,format:"gif",filename:"/html/images/resize1.gif");
        gd_write(gd:im2,format:"gif",filename:"/html/images/resize2.gif");
        gd_write(gd:im3,format:"gif",filename:"/html/images/resize3.gif");
        gd_free(im);
        gd_free(im2);
        gd_free(im3);
        -e "/html/images/resize1.gif";
        -e "/html/images/resize2.gif";
        -e "/html/images/resize3.gif";
}>.
res=<{
        %include "/includes/gd.sn";
        remove("/html/images/bg.gif");
        im=gd_new(width:100,height:110,bgcolor:Yellow,truecolor:true);
        gd_write(gd:im, format:"gif", filename:"/html/images/bg.gif");
        gd_get_size(im);
        gd_get_pixel(gd:im,x:0,y:0);
        gd_free(gd:im);}>.
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"; }>.
res=<{
        remove("/html/images/crop1.gif");
        remove("/html/images/crop2.gif");
        im=gd_new(filename:"/html/images/20130708-1944-londres.jpg");
        im2=gd_crop(gdsrc:im,bgcolor:"#F00BAF",transparent:"bgcolor",srcx:100,srcy:100,srcw:1000,srch:1000,truecolor:true);
        gd_write(gd:im,format:"gif",filename:"/html/images/crop1.gif");
        gd_write(gd:im2,format:"gif",filename:"/html/images/crop2.gif");
        gd_free(im);
        gd_free(im2);
        -e "/html/images/crop1.gif";
        -e "/html/images/crop2.gif";
}>.
res=<{
        remove("/html/images/resize1.gif");
        remove("/html/images/resize2.gif");
        im=gd_new(width:1000,height:1000,bgcolor:"#0000f0");
        im2=gd_new(filename:"/html/images/20130708-1944-londres.jpg");
        gd_resize(gdsrc:im2,gddst:im,dstx:50,dsty:100, dstw:400, dsth:100);
        gd_resize(gdsrc:im2,gddst:im,dstx:50,dsty:400, dstw:400, dsth:100);
        gd_write(gd:im,format:"gif",filename:"/html/images/resize1.gif");
        gd_write(gd:im2,format:"gif",filename:"/html/images/resize2.gif");
        gd_free(im);
        gd_free(im2);
        -e "/html/images/resize1.gif";
        -e "/html/images/resize2.gif";
}>.
res=<{
        remove("/html/images/resize1.gif");
        remove("/html/images/resize2.gif");
        im=gd_new(filename:"/html/images/20130708-1944-londres.jpg");
        im2=gd_resize(gdsrc:im,bgcolor:"#F00BAF",transparent:"bgcolor",dstw:1600,dsth:50,truecolor:true);
        gd_write(gd:im,format:"gif",filename:"/html/images/resize1.gif");
        gd_write(gd:im2,format:"gif",filename:"/html/images/resize2.gif");
        gd_free(im);
        gd_free(im2);
        -e "/html/images/resize1.gif";
        -e "/html/images/resize2.gif";
}>.
res=<{
        remove("/html/images/resize1.gif");
        remove("/html/images/resize2.gif");
        im=gd_new(filename:"/html/images/20130708-1944-londres.jpg");
        im2=gd_resize(gdsrc:im,bgcolor:"#F00BAF",transparent:"bgcolor",dstw:160,truecolor:true);
        gd_write(gd:im,format:"gif",filename:"/html/images/resize1.gif");
        gd_write(gd:im2,format:"gif",filename:"/html/images/resize2.gif");
        gd_free(im);
        gd_free(im2);
        -e "/html/images/resize1.gif";
        -e "/html/images/resize2.gif";
}>.
res=<{
        remove("/html/images/resize1.gif");
        remove("/html/images/resize2.gif");
        im=gd_new(filename:"/html/images/20130708-1944-londres.jpg");
        im2=gd_resize(gdsrc:im,bgcolor:"#F00BAF",transparent:"bgcolor",pourc:40,truecolor:true);
        gd_write(gd:im,format:"gif",filename:"/html/images/resize1.gif");
        gd_write(gd:im2,format:"gif",filename:"/html/images/resize2.gif");
        gd_free(im);
        gd_free(im2);
        -e "/html/images/resize1.gif";
        -e "/html/images/resize2.gif";
}>.
res=<{gd_new();}>.  return .*Parameters filename and width or height must be specify.*
res=<{gd_new(width:100);}>.  return .*Parameters filename and width or height must be specify.*
res=<{gd_new(height:100);}>.  return .*Parameters filename and width or height must be specify.*
res=<{im=gd_new(width:100,height:100); gd_free(im);}>.  return res=.
res=<{im=gd_new(width:100,height:100); gd_free(1);}>.  return .*Parameter 1 of type 1 is not valid in gd_free.*
res=<{im=gd_new(width:100,height:100); gd_free(gd:im);}>.  return res=.
res=<{im=gd_new(filename:"ttoo.jpg"); gd_free(gd:im);}>.  return .*No such file or directory.*
res=<{im=gd_new(format:"xyz",filename:"/html/images/20130708-1944-londres.jpg"); gd_free(gd:im);}>.  return .*Invalid format.*
res=<{im=gd_new(filename:"/html/images/20130708-1944-londres.jpg"); gd_free(gd:im);}>.  return res=.
res=<{
        remove("/html/images/copy1.jpg");
        remove("/html/images/copy1.png");
        remove("/html/images/copy1.gif");
        im=gd_new(filename:"/html/images/20130708-1944-londres.jpg");
        gd_write(gd:im,format:"jpg",filename:"/html/images/copy1.jpg");
        gd_write(gd:im,format:"png",filename:"/html/images/copy1.png");
        gd_write(gd:im,format:"gif",filename:"/html/images/copy1.gif");
        gd_free(im);
        -e "/html/images/copy1.jpg";
        -e "/html/images/copy1.png";
        -e "/html/images/copy1.gif";
}>.

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

© 2024 extenso Inc. All rights reserved.