Code: Select all
Image *images = NULL, *thumbnails = NULL;
ngx_buf_t* buf = NULL;
size_t len;
u_char *inputblob = NULL, *outputblob = NULL;
ImageInfo *image_info = NULL;
ExceptionInfo *exception = NULL;
exception = AcquireExceptionInfo();
buf = &(image_bean->src_image);
inputblob = buf->pos;
len = buf->last - buf->pos;
image_info = CloneImageInfo((ImageInfo *) NULL);
images = BlobToImage(image_info, inputblob, len, exception);
if (exception->severity != UndefinedException || images == (Image *) NULL)
{
if(images != (Image *) NULL)
{
images = DestroyImageList(images);
}
image_info = DestroyImageInfo(image_info);
exception = DestroyExceptionInfo(exception);
return;
}
if( strcmp(output_format, "gif") != 0 || images->next == NULL )
{
// scale the image
thumbnails = SampleImage(images, width, height, exception);
// remove the profile
if (!cglcf->keep_profile)
{
ProfileImage(thumbnails, "*", "", 0, 1);
}
}
if ( strcmp(output_format, "png") == 0 )
{
/*set depth as 8, but it does not work*/
thumbnails=FlipImage(thumbnails, exception);
thumbnails->compression=ZipCompression;
thumbnails->depth=8;
}
len = 0;
if ( thumbnails->next == NULL )
{
outputblob = ImageToBlob(image_info, thumbnails, &len, exception);
}
else
{
outputblob = ImagesToBlob(image_info, thumbnails, &len,exception);
}
if (exception->severity != UndefinedException)
{
if(outputblob != NULL)
{
RelinquishMagickMemory(outputblob);
}
thumbnails = DestroyImageList(thumbnails);
images = DestroyImageList(images);
image_info = DestroyImageInfo(image_info);
exception = DestroyExceptionInfo(exception);
return;
}