Applications/Libgd

From HPC
Revision as of 09:40, 17 March 2017 by Pysdlb (talk | contribs) (Created page with "__TOC__ ==Application Details== *Description: GD is an open source code library for the dynamic creation of images by programmers. GD is written in C, and "wrappers" are avail...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation , search

Application Details

  • Description: GD is an open source code library for the dynamic creation of images by programmers. GD is written in C, and "wrappers" are available for Perl, PHP and other languages. GD creates PNG, JPEG, GIF, WebP, XPM, BMP images, among other formats. GD is commonly used to generate charts, graphics, thumbnails, and most anything else, on the fly. While not restricted to use on the web, the most common applications of GD involve website development.
  • Version: 2.2.3 (compiled with gcc)
  • Module: gcc/2.2.3
  • Licence: GNU

Usage Examples

Module

[username@login01 ~]$ module add libgd/gcc/2.2.3

Compilation

'Libgd is a library for use either with a compiled binary that requires it, or it could be required at compilation time also.

A typical code snippet requiring is shown below:


#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>

void mySavePng(char *filename,
  gdImagePtr im)
{
  FILE *out;
  int size;
  char *data;
  out = fopen("filename, "wb");
  if (!out) {
    /* Error */
  }
  data = (char *) gdImagePngPtr(im, &size);
  if (!data) {
    /* Error */
  }
  if (fwrite(data, 1, size, out) != size) {
    /* Error */
  }
  if (fclose(out) != 0) {
    /* Error */
  }
  gdFree(data);
}

Compilation is carried out below, in this example the gcc compiler is used. However, the applies similarly to the Intel compiler too.


gcc -o savePNG savePNG.c -lm -lgd


Further Information

https://libgd.github.io