Example #1
0
/* create wbmp
 * -----------
 * create an empty wbmp
 */
Wbmp *createwbmp(int width, int height, int color)
{
	int i;
	Wbmp *wbmp;

	if((wbmp = (Wbmp *)gdMalloc(sizeof (Wbmp))) == NULL) {
		return (NULL);
	}

	if(overflow2(sizeof(int), width)) {
		gdFree(wbmp);
		return NULL;
	}

	if(overflow2(sizeof(int) * width, height)) {
		gdFree(wbmp);
		return NULL;
	}

	if((wbmp->bitmap = (int *)gdMalloc(sizeof(int) * width * height)) == NULL) {
		gdFree(wbmp);
		return NULL;
	}

	wbmp->width = width;
	wbmp->height = height;

	for(i = 0; i < width * height; wbmp->bitmap[i++] = color);

	return wbmp;
}
Example #2
0
static void
gdFreeDynamicCtx (struct gdIOCtx *ctx)
{
  dynamicPtr *dp;
  dpIOCtx *dctx;

  dctx = (dpIOCtx *) ctx;
  dp = dctx->dp;

  gdFree (ctx);

  /* clean up the data block and return it */
  /* 2.0.21: never free memory we don't own */
  if ((dp->data != NULL) && (dp->freeOK))
    {
      gdFree (dp->data);
      dp->data = NULL;
    }

  dp->realSize = 0;
  dp->logicalSize = 0;

  gdFree (dp);

}
Example #3
0
void gdClipSetFree(gdImagePtr im)
{	if (im->clip)
	{	gdFree (im->clip->list);
		gdFree (im->clip);
		im->clip = 0;
	}
}
Example #4
0
/*!	\brief Cleans up a TGA structure.
 *	Dereferences the bitmap referenced in a TGA structure, then the structure itself
 *	\param tga Pointer to TGA structure
 */
void free_tga(oTga * tga)
{
	if (tga) {
		if (tga->ident)
			gdFree(tga->ident);
		if (tga->bitmap)
			gdFree(tga->bitmap);
		gdFree(tga);
	}
}
Example #5
0
/*!	\brief Cleans up a TGA structure.
 *	Dereferences the bitmap referenced in a TGA structure, then the structure itself
 *	\param tga Pointer to TGA structure
 */
void free_tga(oTga * tga) {
	if (tga) {
		if (tga->ident) {
			gdFree(tga->ident);
			tga->ident = NULL;
		}
		if (tga->bitmap) {
			gdFree(tga->bitmap);
			tga->bitmap = NULL;
		}
		gdFree(tga);
		tga = NULL;
	}
}
Example #6
0
void
gdCacheDelete( gdCache_head_t *head )
{
	gdCache_element_t *elem, *prev;

	elem = head->mru;
	while(elem) {
		(*(head->gdCacheRelease))(elem->userdata);
		prev = elem;
		elem = elem->next;
		gdFree((char *)prev);
	}
	gdFree((char *)head);
}
Example #7
0
static void gdFreeDynamicCtx (struct gdIOCtx *ctx)
{
	dynamicPtr *dp;
	dpIOCtx *dctx;

	dctx = (dpIOCtx *) ctx;
	dp = dctx->dp;

	gdFree(ctx);

	dp->realSize = 0;
	dp->logicalSize = 0;

	gdFree(dp);
}
Example #8
0
int
main ()
{
  unsigned char input[BUFSIZ];
  unsigned char *output;
  unsigned char *str;
  int c, i = 0;

  while ((c = fgetc (stdin)) != '\n' && i < BUFSIZ)
    input[i++] = c;
  input[i] = '\0';

  printf ("input : %d bytes\n", strlen ((const char *) input));
  printf ("output: %d bytes\n", strwidth (input));

  output = (unsigned char *) gdMalloc (BUFSIZ);
  any2eucjp (output, input, BUFSIZ);
  str = output;
  while (*str != '\0')
    putchar (*(str++));
  putchar ('\n');
  gdFree (output);

  return 0;
}
Example #9
0
BGD_DECLARE(void *) gdDPExtractData (struct gdIOCtx *ctx, int *size)
{
  dynamicPtr *dp;
  dpIOCtx *dctx;
  void *data;

  dctx = (dpIOCtx *) ctx;
  dp = dctx->dp;

  /* clean up the data block and return it */
  if (dp->dataGood)
    {
      trimDynamic (dp);
      *size = dp->logicalSize;
      data = dp->data;
    }
  else
    {
      *size = 0;
      data = NULL;
      /* 2.0.21: never free memory we don't own */
      if ((dp->data != NULL) && (dp->freeOK))
	{
	  gdFree (dp->data);
	}
    }

  dp->data = NULL;
  dp->realSize = 0;
  dp->logicalSize = 0;

  return data;
}
Example #10
0
int main()
{
	gdImagePtr im;
	int white, black;
	char *path;

	im = gdImageCreateTrueColor(6, 6);
	white = gdImageColorAllocate(im, 255, 255, 255);
	black = gdImageColorAllocate(im, 0, 0, 0);
	gdImageFilledRectangle(im, 0,0, 5,5, white);

	gdImageLine(im, 4,4, 4,4, black);
	gdImageLine(im, 1,4, 2,4, black);
	gdImageLine(im, 4,1, 4,2, black);

	gdImageSetAntiAliased(im, black);
	gdImageLine(im, 1,1, 1,1, gdAntiAliased);

	path = gdTestFilePath2("gdimageline", "bug00315_exp.png");
	gdAssertImageEqualsToFile(path, im);
	gdFree(path);

	gdImageDestroy(im);

	return gdNumFailures();
}
Example #11
0
/* grow (or shrink) dynamic pointer */
static int
gdReallocDynamic (dynamicPtr * dp, int required)
{
  void *newPtr;

  /* First try gdRealloc().  If that doesn't work, make a new
     memory block and copy. */
  if ((newPtr = gdRealloc (dp->data, required)))
    {
      dp->realSize = required;
      dp->data = newPtr;
      return TRUE;
    }

  /* create a new pointer */
  newPtr = gdMalloc (required);
  if (!newPtr)
    {
      dp->dataGood = FALSE;
      return FALSE;
    }

  /* copy the old data into it */
  memcpy (newPtr, dp->data, dp->logicalSize);
  gdFree (dp->data);
  dp->data = newPtr;

  dp->realSize = required;
  return TRUE;
}
Example #12
0
static gdImagePtr _gd2CreateFromFile (gdIOCtxPtr in, int *sx, int *sy, int *cs, int *vers, int *fmt, int *ncx, int *ncy, t_chunk_info ** cidx)
{
	gdImagePtr im;

	if (_gd2GetHeader (in, sx, sy, cs, vers, fmt, ncx, ncy, cidx) != 1) {
		GD2_DBG(php_gd_error("Bad GD2 header"));
		goto fail1;
	}

	if (gd2_truecolor(*fmt)) {
		im = gdImageCreateTrueColor(*sx, *sy);
	} else {
		im = gdImageCreate(*sx, *sy);
	}
	if (im == NULL) {
		GD2_DBG(php_gd_error("Could not create gdImage"));
		goto fail2;
	}

	if (!_gdGetColors(in, im, (*vers) == 2)) {
		GD2_DBG(php_gd_error("Could not read color palette"));
		goto fail3;
	}
	GD2_DBG(php_gd_error("Image palette completed: %d colours", im->colorsTotal));

	return im;

fail3:
	gdImageDestroy(im);
fail2:
	gdFree(*cidx);
fail1:
	return 0;
}
Example #13
0
int
main(void)
{
	gdImagePtr im;
	int white, black, r;
	gdPointPtr points;

	im = gdImageCreate(100, 100);
	if (!im) exit(EXIT_FAILURE);
	white = gdImageColorAllocate(im, 0xff, 0xff, 0xff);
	black = gdImageColorAllocate(im, 0, 0, 0);
	gdImageFilledRectangle(im, 0, 0, 99, 99, white);
	points = (gdPointPtr)gdCalloc(3, sizeof(gdPoint));
	if (!points) {
		gdImageDestroy(im);
		exit(EXIT_FAILURE);
	}
	points[0].x = 10;
	points[0].y = 10;
	points[1].x = 50;
	points[1].y = 70;
	points[2].x = 90;
	points[2].y = 30;
	gdImageOpenPolygon(im, points, 3, black);
	r = gdAssertImageEqualsToFile(GDTEST_TOP_DIR "/gdimageopenpolygon/gdimageopenpolygon3.png", im);
	gdFree(points);
	gdImageDestroy(im);
	if (!r) exit(EXIT_FAILURE);
	return EXIT_SUCCESS;
}
Example #14
0
unsigned char* convertToBase64(gdImagePtr im) {
	// Convert the image to 1peg, default quality, getting
	// back pointer to allocated bytes and length
	int size;
	void* jpegbytes = gdImageJpegPtr(im, &size, 75);
	size_t encodedsize = 0;
	
	unsigned char* source = (unsigned char*) jpegbytes;
	unsigned char* b64codes = NULL;
	
	// Invoke base64 encoder first time just to get length of
	// base 64 string
	base64_encode(b64codes, &encodedsize, source, size);
	
	// Allocate space
	b64codes = malloc(encodedsize + 1);
	
	// Convert
	int res = base64_encode(b64codes, &encodedsize, source, size);
	gdFree(jpegbytes);
	
	if (res != 0) {
		printf("Failed to base 64 encode data\n");
		if (b64codes != NULL)
			free(b64codes);
		return NULL;
	}
	
	return b64codes;
}
Example #15
0
BGD_DECLARE(gdIOCtx *) gdNewDynamicCtxEx (int initialSize, void *data, int freeOKFlag)
{
  dpIOCtx *ctx;
  dynamicPtr *dp;

  ctx = (dpIOCtx *) gdMalloc (sizeof (dpIOCtx));
  if (ctx == NULL)
    {
      return NULL;
    }

  dp = newDynamic (initialSize, data, freeOKFlag);
  if (!dp)
    {
      gdFree (ctx);
      return NULL;
    };

  ctx->dp = dp;

  ctx->ctx.getC = dynamicGetchar;
  ctx->ctx.putC = dynamicPutchar;

  ctx->ctx.getBuf = dynamicGetbuf;
  ctx->ctx.putBuf = dynamicPutbuf;

  ctx->ctx.seek = dynamicSeek;
  ctx->ctx.tell = dynamicTell;

  ctx->ctx.gd_free = gdFreeDynamicCtx;

  return (gdIOCtx *) ctx;
}
Example #16
0
void * gdDPExtractData (struct gdIOCtx *ctx, int *size)
{
	dynamicPtr *dp;
	dpIOCtx *dctx;
	void *data;

	dctx = (dpIOCtx *) ctx;
	dp = dctx->dp;

	/* clean up the data block and return it */
	if (dp->dataGood) {
		trimDynamic (dp);
		*size = dp->logicalSize;
		data = dp->data;
	} else {
		*size = 0;
		data = NULL;
		if (dp->data != NULL && dp->freeOK) {
			gdFree(dp->data);
		}
	}

	dp->data = NULL;
	dp->realSize = 0;
	dp->logicalSize = 0;

	return data;
}
Example #17
0
int main()
{
	gdImagePtr src, dst;
	int r, g, b;
	void *p;
	int size = 0;
	int status = 0;
	CuTestImageResult result = {0, 0};

	src = gdImageCreate(100, 100);
	if (src == NULL) {
		gdTestErrorMsg("could not create src\n");
		return 1;
	}
	r = gdImageColorAllocate(src, 0xFF, 0, 0);
	g = gdImageColorAllocate(src, 0, 0xFF, 0);
	b = gdImageColorAllocate(src, 0, 0, 0xFF);
	gdImageFilledRectangle(src, 0, 0, 99, 99, r);
	gdImageRectangle(src, 20, 20, 79, 79, g);
	gdImageEllipse(src, 70, 25, 30, 20, b);

#define OUTPUT_GD2(x) do {												\
		FILE *fp = gdTestTempFp();										\
		gdImageGd2(x, fp, (GD2_CHUNKSIZE_MIN+GD2_CHUNKSIZE_MAX)/2, GD2_FMT_COMPRESSED); \
		fclose(fp);														\
	} while (0)

	OUTPUT_GD2(src);
	p = gdImageGd2Ptr(src, (GD2_CHUNKSIZE_MIN+GD2_CHUNKSIZE_MAX)/2, GD2_FMT_COMPRESSED, &size);
	if (p == NULL) {
		status = 1;
		gdTestErrorMsg("p is null\n");
		goto door0;
	}
	if (size <= 0) {
		status = 1;
		gdTestErrorMsg("size is non-positive\n");
		goto door1;
	}

	dst = gdImageCreateFromGd2Ptr(size, p);
	if (dst == NULL) {
		status = 1;
		gdTestErrorMsg("could not create dst\n");
		goto door1;
	}
	OUTPUT_GD2(dst);
	gdTestImageDiff(src, dst, NULL, &result);
	if (result.pixels_changed > 0) {
		status = 1;
		gdTestErrorMsg("pixels changed: %d\n", result.pixels_changed);
	}
	gdImageDestroy(dst);
door1:
	gdFree(p);
door0:
	gdImageDestroy(src);
	return status;
}
Example #18
0
int getTruetypeTextBBoxGD(rendererVTableObj *renderer, char **fonts, int numfonts, double size, char *string, rectObj *rect, double **advances, int bAdjustBaseline) {
#ifdef USE_GD_FT
   int bbox[8];
   char *error;
   if(advances) {
#if defined (GD_HAS_FTEX_XSHOW)
      char *s;
      int k;
      gdFTStringExtra strex;
      strex.flags = gdFTEX_XSHOW;
      error = gdImageStringFTEx(NULL, bbox, 0, fonts[0], size, 0, 0, 0, string, &strex);
      if(error) {
         msSetError(MS_TTFERR, error, "gdImageStringFTEx()");
         return(MS_FAILURE);
      }

      *advances = (double*)malloc( strlen(string) * sizeof(double) );
      MS_CHECK_ALLOC(*advances, strlen(string) * sizeof(double), MS_FAILURE);
      s = strex.xshow;
      k = 0;
      /* TODO this smells buggy and can cause errors at a higher level. strlen NOK here*/
      while ( *s && k < strlen(string) ) {
         (*advances)[k++] = atof(s);      
         while ( *s && *s != ' ')
            s++;
         if ( *s == ' ' )
            s++;
      }

      gdFree(strex.xshow); /* done with character advances */

      rect->minx = bbox[0];
      rect->miny = bbox[5];
      rect->maxx = bbox[2];
      rect->maxy = bbox[1];
      return MS_SUCCESS;
#else
      msSetError(MS_TTFERR, "gdImageStringFTEx support is not available or is not current enough (requires 2.0.29 or higher).", "msGetTruetypeTextBBox()");
      return(MS_FAILURE);
#endif
   } else {
      error = gdImageStringFT(NULL, bbox, 0, fonts[0], size, 0, 0, 0, string);
      if(error) {
         msSetError(MS_TTFERR, error, "msGetTruetypeTextBBox()");
         return(MS_FAILURE);
      }

      rect->minx = bbox[0];
      rect->miny = bbox[5];
      rect->maxx = bbox[2];
      rect->maxy = bbox[1];
      return MS_SUCCESS;
   }
#else
    msSetError(MS_TTFERR,"Truetype support not available", "getTruetypeTextBBoxGD()");
    return(MS_FAILURE);
#endif
}
Example #19
0
static int scanForImage( lsi_cb_param_t * rec )
{
    off_t offset = 0;
    int iSrcSize, iDestSize, iWidth = 0, iHeight = 0, iLen = 0;
    void *pRespBodyBuf, *pSrcBuf, *pDestBuf;
    const char *ptr, *pDimensions;
    MyData *myData = (MyData *)g_api->get_module_data(rec->_session, &MNAME, LSI_MODULE_DATA_HTTP);
    lsr_xpool_t *pPool = g_api->get_session_pool( rec->_session );
    
    if ( parseParameters( rec, myData ) == 0 )
    {
        
        pDimensions = g_api->get_req_query_string( rec->_session, &iLen );
        if ( (iLen == 0)
            || (getReqDimensions( pDimensions, iLen, &iWidth, &iHeight ) != 0)
        )
        {
            return LSI_RET_OK;
        }
        pRespBodyBuf = g_api->get_resp_body_buf( rec->_session );
        if ( !pRespBodyBuf )
            return LSI_RET_OK;
        iSrcSize = g_api->get_body_buf_size( pRespBodyBuf );
        pSrcBuf = lsr_xpool_alloc( pPool, iSrcSize );
        while( !g_api->is_body_buf_eof( pRespBodyBuf, offset ) )
        {
            ptr = g_api->acquire_body_buf_block( pRespBodyBuf, offset, &iLen );
            if ( !ptr )
                break;
            memcpy( pSrcBuf + offset, ptr, iLen );
            g_api->release_body_buf_block( pRespBodyBuf, offset );
            offset += iLen;
        }
    }
    else
    {
        return LSI_RET_OK;
    }
    g_api->reset_body_buf( pRespBodyBuf );
    if ( g_api->append_body_buf( pRespBodyBuf, pSrcBuf, iSrcSize ) != iSrcSize )
        return LSI_RET_ERROR;
    iSrcSize = g_api->get_body_buf_size( pRespBodyBuf );
    
    pDestBuf = resizeImage( pSrcBuf, iSrcSize, iWidth, iHeight, myData, &iDestSize );
    if ( !pDestBuf )
        return LSI_RET_ERROR;    
    
    while( g_api->is_resp_buffer_available( rec->_session ) <= 0 );
    
    
    g_api->reset_body_buf( pRespBodyBuf );
    if ( g_api->append_body_buf( pRespBodyBuf, pDestBuf, iDestSize ) != iDestSize )
        return LSI_RET_ERROR;
    g_api->set_resp_content_length( rec->_session, iDestSize );
    
    gdFree( pDestBuf );
    return LSI_RET_OK;
}
Example #20
0
value ImagePngData(value img) {
	ImageData _img = getImage(img);
	int size;
	void *ptr = gdImagePngPtr(imageImage(_img),&size);
	buffer ret = alloc_buffer(NULL);
	buffer_append_sub(ret,ptr,size);
	gdFree(ptr);
	return buffer_to_string(ret);
}
Example #21
0
int main()
{
	gdImagePtr src, dst;
	int b;
	void *p;
	int size = 0;
	int status = 0;
	CuTestImageResult result = {0, 0};

	src = gdImageCreate(100, 100);
	if (src == NULL) {
		printf("could not create src\n");
		return 1;
	}
	gdImageColorAllocate(src, 0xFF, 0xFF, 0xFF); /* allocate white for background color */
	b = gdImageColorAllocate(src, 0, 0, 0);
	gdImageRectangle(src, 20, 20, 79, 79, b);
	gdImageEllipse(src, 70, 25, 30, 20, b);

#define OUTPUT_WBMP(name) do {							\
		FILE *fp = gdTestTempFp();						\
		gdImageWBMP(name, 1, fp);						\
		fclose(fp);										\
	} while (0)

	OUTPUT_WBMP(src);
	p = gdImageWBMPPtr(src, &size, 1);
	if (p == NULL) {
		status = 1;
		printf("p is null\n");
		goto door0;
	}
	if (size <= 0) {
		status = 1;
		printf("size is non-positive\n");
		goto door1;
	}

	dst = gdImageCreateFromWBMPPtr(size, p);
	if (dst == NULL) {
		status = 1;
		printf("could not create dst\n");
		goto door1;
	}
	OUTPUT_WBMP(dst);
	gdTestImageDiff(src, dst, NULL, &result);
	if (result.pixels_changed > 0) {
		status = 1;
		printf("pixels changed: %d\n", result.pixels_changed);
	}
	gdImageDestroy(dst);
door1:
	gdFree(p);
door0:
	gdImageDestroy(src);
	return status;
}
Example #22
0
value ImageJpegData(value img, value quality) {
	ImageData _img = getImage(img);
	int _quality = val_int(quality);
	int size;
	void *ptr = gdImageJpegPtr(imageImage(_img),&size,_quality);
	buffer ret = alloc_buffer(NULL);
	buffer_append_sub(ret,ptr,size);
	gdFree(ptr);
	return buffer_to_string(ret);
}
void ngx_http_small_light_gd_term(void *data)
{
    ngx_http_small_light_ctx_t *ctx;
    ngx_http_small_light_gd_ctx_t *ictx;
    ctx = (ngx_http_small_light_ctx_t *)data;
    ictx = (ngx_http_small_light_gd_ctx_t *)ctx->ictx;

    if (ictx->complete) {
        gdFree(ctx->content);
    }
}
Example #24
0
unsigned int
strwidth (unsigned char *s)
{
  unsigned char *t;
  unsigned int i;

  t = (unsigned char *) gdMalloc (BUFSIZ);
  any2eucjp (t, s, BUFSIZ);
  i = strlen (t);
  gdFree (t);
  return i;
}
static void
ngx_pngquant_free_true_color_image_data(gdImagePtr oim)
{
    int i;
    oim->trueColor = 0;
    /* Junk the truecolor pixels */
    for (i = 0; i < oim->sy; i++) {
            gdFree (oim->tpixels[i]);
    }
    free (oim->tpixels);
    oim->tpixels = 0;
}
Example #26
0
/* bring the palette colors in im2 to be closer to im1
 *
 */
int gdImageColorMatch (gdImagePtr im1, gdImagePtr im2)
{
	unsigned long *buf; /* stores our calculations */
	unsigned long *bp; /* buf ptr */
	int color, rgb;
	int x,y;
	int count;

	if( !im1->trueColor ) {
		return -1; /* im1 must be True Color */
	}
	if( im2->trueColor ) {
		return -2; /* im2 must be indexed */
	}
	if( (im1->sx != im2->sx) || (im1->sy != im2->sy) ) {
		return -3; /* the images are meant to be the same dimensions */
	}
	if (im2->colorsTotal<1) {
		return -4; /* At least 1 color must be allocated */
	}

	buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * im2->colorsTotal, 0);
	memset( buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );

	for (x=0; x<im1->sx; x++) {
		for( y=0; y<im1->sy; y++ ) {
			color = im2->pixels[y][x];
			rgb = im1->tpixels[y][x];
			bp = buf + (color * 5);
			(*(bp++))++;
			*(bp++) += gdTrueColorGetRed(rgb);
			*(bp++) += gdTrueColorGetGreen(rgb);
			*(bp++) += gdTrueColorGetBlue(rgb);
			*(bp++) += gdTrueColorGetAlpha(rgb);
		}
	}
	bp = buf;
	for (color=0; color<im2->colorsTotal; color++) {
		count = *(bp++);
		if( count > 0 ) {
			im2->red[color]		= *(bp++) / count;
			im2->green[color]	= *(bp++) / count;
			im2->blue[color]	= *(bp++) / count;
			im2->alpha[color]	= *(bp++) / count;
		} else {
			bp += 4;
		}
	}
	gdFree(buf);
	return 0;
}
Example #27
0
void gdImageRelease (GDImage *image) {
    if (!_gdObjectRelease(gdObject(image)))
        return;

    gdImagePoolRemove(image);

    if (image->data != NULL)
        gdZFree(&(image->name));

    if (image->data != NULL)
        gdZFree(&(image->data));

    if (_gdObjectInternalAlloc(image))
        gdFree(image);
}
Example #28
0
static void
gdFreeDynamicCtx (struct gdIOCtx *ctx)
{
  dynamicPtr *dp;
  dpIOCtx *dctx;

  dctx = (dpIOCtx *) ctx;
  dp = dctx->dp;

  gdFree (ctx);

  /* clean up the data block and return it */
  if (dp->data != NULL)
    {
      gdFree (dp->data);
      dp->data = NULL;
    }

  dp->realSize = 0;
  dp->logicalSize = 0;

  gdFree (dp);

}
Example #29
0
int ThumbCacheAdd(FILE *tc, const char *filename, time_t mtime) {
	gdImagePtr thumb = NULL;
	unsigned int thumbsize, imgsize, offset;
	void *thumbdata;
	TCENTRY tcent;
	int status = 0, closetc = 0;

	if (!filename)
		return 0;

	if (!tc) {
		closetc = 1;
		tc = fopen(thumb_cache_fn, "rb+");
		if (!tc)
			goto end;

		if (fseek(tc, 0, SEEK_END))
			goto end;
	}

	thumb = ThumbCreate(filename, &imgsize);
	if (!thumb)
		goto end;

	thumbdata = gdImagePngPtr(thumb, (int *)&thumbsize);
	if (!thumbdata)
		goto end;

	tcent.mtime      = mtime;
	tcent.thumbfsize = thumbsize;
	tcent.thumbkey   = _ThumbCalcKey(thumb->tpixels);

	offset = _ThumbCacheWriteEntry(tc, &tcent, filename, thumbdata);
	if (!offset)
		goto end;

	status = _ThumbCacheUpdateStructures(filename, &tcent, offset, 0);

end:
	if (thumb)
		gdImageDestroy(thumb);
	if (thumbdata)
		gdFree(thumbdata);
	if (tc && closetc)
		fclose(tc);

	return status;
}
static void write_img(void * conf)
{
	ngx_image_conf_t *info = conf;
	FILE * fp;
	if(info->img_data == NULL)
	{
		return;
	}
	fp = fopen(info->dest_file,"wb");
	if(fp)
	{
		fwrite(info->img_data,sizeof(char),info->img_size,fp);
		fclose(fp);
	}
    gdFree(info->img_data);
}