Tuesday, 15 November 2016

GD LIBRARY

GD hi C graphics library .jpegs, .pngs, leh .wbmps. thlalak siamna leh suasamna ber a ni a. .gifs file a support lo va. Version thar zelah chuan a support thuai a rinawm bawk. PNG hian gif zia zawng zawng a neih tho bawk avangin lungngaihna tur erawh a awm hran lo.

INSTALLATION

GD hmang thei tur chuan php_gd2.dll file hi installation package-ah a tel sa vek a. php.ini hawn a extension=php_gd2.dll line kha uncomment mai tur a ni.php.ini file-a enable kher lo pawhin a hnuaia code hmang hian enable theih a ni bawk.
dl(‘php_gd2.dll’);

I host chuan UNIX system nge Windows system an hman i chian loh chuan..a hnuaia mi ang hian GD library i load thei ang.

<?php
if(!extension_loaded(‘gd’)){
     if(strtoupper(substr(PHP_OS, 3)) == “WIN”){
        dl(‘php_gd2.dll’);
        }else{
           dl(‘gd.so’);
        }
  }
?>

IMAGE RESOURCE SIAM LEH HMAN DAN

Image siam nan hian GD hian functions pahnih a nei a, an pahnih hian argument pahnih width leh height an nei ve ve a.

ImageCreate(width, height)
ImageCreateTrueColor(width, height)

Hei bakah hian GD hian file awmsa atang image siamna function a nei bawk a. ImageCreate() function hi kan zir hmasa phawt ang.

ImageCreate(); kan hriat tawh angin Width leh Height neia blank image siam tawpna a ni deuh tlawng a. COlor a hman hi Index Color a nih avangin color chi hrang 256 a awm thei tihna a ni.

<?php
if(!extension_loaded(‘gd’)){
    if(strtoupper(substr(PHP_OS, 3)) == “WIN”){
        dl(‘php_gd2.dll’);
      }else{
        dl(‘gd.so’);
        }
    }
$imageResource = ImageCreate(100, 100);
?>

Image 100px width leh 100px height kan lo nei ta a. Kan duh dan takin GD library function min chhawpchhuah hrang hrangin kan suasam thei tawh tihna a ni. Kan luhchilh tak tak hmain ImageCreateTrueColor() function chungchang hi tlem lo bih leh phawt ila. ImageCreate() ang deuh tho a ni a, a danglam bikna chu Index Color pallete hmang lovin True Color Pallete a hmang hi a ni. Chuvangin element hrang hrang nei thei tur complex graphic siam nan duhthusam a ni.

Geometric shape ziah kual vel tak tak hmain color thlan leh hman dan i hriat a pawimawh phawt a. Color function pariat(8) a hnuaia mi ang hian kan nei thei a.

1. ImageColorAllocate(resource image, int red, int green, int blue)
2. ImageFill(resource image, int x, int y, int color)
3. ImageColorTransparent(resource image, int color)
4. ImageTrueColorToPalette(resource image, bool dither, int colors)
5. ImageColorsTotal(resource image)
6. ImageColorAt(resource image, int x, int y)
7. ImageColorsForIndex(resource image, int index)
8. ImageColorSet(resource image, int index, int red, int green, int blue)

Kan hmuh ang hian image resource hi argument hmasa bera tan an hmang vek a, argument mal te te hi zir chian a, nal chuan GD kan hman dan tur chu a lang uai nghal a ni mai. (int = integer tihna.)

ImageColorAllocate() hian argument pali a nei a, a hmasa ber hi resource image a ni a. int red hi thlalak a red color value sawina a ni a, a dawttu hi green value a ni leh a, atawp bera mi hi blue a ni ve thung. blue pek tam i duh chuan a number tihtam mai tur a ni. RGB color awmzia i la hriat ngai loh chuan color value hi 0-255 a awm thei tih tal hria la, a tawk viau mai. Entirnan black siam tur chuan a hnuaia mi ang hian

$black = ImageColorAllocate($someImageResource, 0, 0, 0);

Next-ah chhunzawm a ni ang.