Exemplo n.º 1
0
int fuppes_transcoder_transcode_image_mem(plugin_info* plugin,
	                                const unsigned char** inBuffer,
																	size_t inSize,
		                              unsigned char** outBuffer,
																	size_t* outSize,
																	int width, int height,
																	int less,	int greater)
{
	MagickBooleanType status;
	MagickWand* wand = NewMagickWand();
	
	//printf("magickWand %d\n", 1);
	
	status = MagickReadImageBlob(wand, *inBuffer, inSize);
	if(status == MagickFalse) {
		plugin->cb.log(plugin, 0, __FILE__, __LINE__,
								"error reading image from buffer. size: %d", inSize);
		wand = DestroyMagickWand(wand);
		return -1;
	}

	//printf("magickWand %d\n", 2);
	
	MagickWand* wandOut;
	char geometry[123];
	sprintf(&geometry, "%dx%d", width, height);
	//char* geometry = "250x250";
	wandOut = MagickTransformImage(wand, "", geometry);
	wand = DestroyMagickWand(wand);
	if(wandOut == NULL) {		
		return -1;
	}

	//printf("magickWand %d\n", 3);
	
	//MagickBooleanType MagickSetFormat(MagickWand *wand,const char *format)
	
	size_t length;
	unsigned char* blob;
	blob = MagickGetImageBlob(wandOut, &length);
	*outBuffer = realloc(*outBuffer, length);
	memcpy(*outBuffer, blob, length);
	*outSize = length;
	MagickRelinquishMemory(blob);
	
	//printf("magickWand %d, %d\n", 4, *outSize);
	
	//MagickRelinquishMemory(wandOut);
	wandOut = DestroyMagickWand(wandOut);
	return 0;	
}
Exemplo n.º 2
0
void
im_leave (im_env_t *env)
{
  if (NULL != env->ime_target_magick_wand)
    DestroyMagickWand (env->ime_target_magick_wand);
  DestroyMagickWand (env->ime_magick_wand);
  if (NULL != env->ime_drawing_wand)
    DestroyDrawingWand (env->ime_drawing_wand);
  if (NULL != env->ime_background)
    DestroyPixelWand (env->ime_background);
  im_dbg_printf (("IM %p: about to leave %s()...", env, env->ime_bifname));
  /* mutex_leave (im_lib_mutex); */
  im_dbg_printf (("... IM %p: left\n", env));
}
Exemplo n.º 3
0
unsigned char *get_transition_image_blob(char *file_buf, int buf_size,
		size_t * thumbnail_size, img_transition_info *image_transition_info) {

	unsigned char *image_data = NULL;

	if (file_buf == NULL)
		return NULL;
	if (image_transition_info == NULL)
		return NULL;
	if ((0 == image_transition_info->is_rotate)
			&& ('\0' == image_transition_info->transition_str[0])
			&& (0 == image_transition_info->is_quality))
		return NULL;
	MagickBooleanType status;
	MagickWand *magick_wand = NULL;
	magick_wand = NewMagickWand();
	status = MagickReadImageBlob(magick_wand, file_buf, buf_size);
	if (status == MagickFalse) {
		ThrowWandException(magick_wand);
		return NULL;
	}
	image_data = covert_image(magick_wand, image_transition_info,
			thumbnail_size);
	magick_wand = DestroyMagickWand(magick_wand);
	return image_data;

}
Exemplo n.º 4
0
int magickUnsharpMaskImage(const char *imageFile, const char *outputImage, double radius, double sigma, double amount, double threshold){
    MagickBooleanType status;

    MagickWand *magick_wand;

    /*
      Read an image.
    */
    MagickWandGenesis();
    magick_wand=NewMagickWand();  
    status=MagickReadImage(magick_wand, (char *)imageFile);
    if (status == MagickFalse){
      ThrowWandException(magick_wand);
    }
    /*
      Turn the images into a thumbnail sequence.
    */
//    MagickResetIterator(magick_wand);
//    while (MagickNextImage(magick_wand) != MagickFalse)
      MagickUnsharpMaskImage(magick_wand, radius, sigma, amount, threshold);
    /*
      Write the image then destroy it.
    */
    status=MagickWriteImages(magick_wand, (char *)outputImage, MagickTrue);
    if (status == MagickFalse)
      ThrowWandException(magick_wand);
    magick_wand=DestroyMagickWand(magick_wand);
    MagickWandTerminus();
    return status;
}
Exemplo n.º 5
0
int magickChopImage(const char *imageFile, const char *outputImage, int width, int height, int xPos, int yPos){
    MagickBooleanType status;

    MagickWand *magick_wand;

    /*
      Read an image.
    */
    MagickWandGenesis();
    magick_wand=NewMagickWand();  
    status=MagickReadImage(magick_wand, (char *)imageFile);
    if (status == MagickFalse){
      ThrowWandException(magick_wand);
    }
    /*
      Turn the images into a thumbnail sequence.
    */
    MagickResetIterator(magick_wand);
    while (MagickNextImage(magick_wand) != MagickFalse)
      MagickChopImage(magick_wand, width, height, xPos, yPos);
    /*
      Write the image then destroy it.
    */
    status=MagickWriteImages(magick_wand, (char *)outputImage, MagickTrue);
    if (status == MagickFalse)
      ThrowWandException(magick_wand);
    magick_wand=DestroyMagickWand(magick_wand);
    MagickWandTerminus();
    return status;
}
Exemplo n.º 6
0
int magickCompressImage(const char *imageFile, const char *outputImage, const char *format, int compressionType, double compressionRate){
    MagickBooleanType status;

    MagickWand *magick_wand;

    /*
      Read an image.
    */
 //   printf("compressionRate: %d", compressionRate);
    MagickWandGenesis();
    magick_wand=NewMagickWand();  
    status=MagickReadImage(magick_wand, (char *)imageFile);
    if (status == MagickFalse){
      ThrowWandException(magick_wand);
    }
    /*
      Turn the images into a thumbnail sequence.
    */
//    MagickResetIterator(magick_wand);
//    while (MagickNextImage(magick_wand) != MagickFalse){
        MagickSetFormat(magick_wand, (char *)format);
        MagickSetImageCompression(magick_wand, compressionType);
        MagickSetImageCompressionQuality(magick_wand, compressionRate);
//    }

    /*
      Write the image then destroy it.
    */
    status=MagickWriteImages(magick_wand, (char *)outputImage, MagickTrue);
    if (status == MagickFalse)
      ThrowWandException(magick_wand);
    magick_wand=DestroyMagickWand(magick_wand);
    MagickWandTerminus();
    return status;
}
Exemplo n.º 7
0
int magickResizeImage(const char *imageFile, const char *outputImage, int columns, int rows, int magickFilter, double blur){
    MagickBooleanType status;

    MagickWand *magick_wand;

    /*
      Read an image.
    */
    MagickWandGenesis();
    magick_wand=NewMagickWand();  
    status=MagickReadImage(magick_wand, (char *)imageFile);
    if (status == MagickFalse){
      ThrowWandException(magick_wand);
    }
    /*
      Turn the images into a thumbnail sequence.
    */
    MagickResetIterator(magick_wand);
    while (MagickNextImage(magick_wand) != MagickFalse)
      MagickResizeImage(magick_wand, columns, rows, LanczosFilter, blur);
    /*
      Write the image then destroy it.
    */
    status=MagickWriteImages(magick_wand, (char *)outputImage, MagickTrue);
    if (status == MagickFalse)
      ThrowWandException(magick_wand);
    magick_wand=DestroyMagickWand(magick_wand);
    MagickWandTerminus();
    return status;
    
}
Exemplo n.º 8
0
int magickRotateImage(const char *imageFile, const char *outputImage, double degree){
    MagickBooleanType status;
    MagickWand *magick_wand;

    PixelWand * bg = malloc(sizeof(PixelWand *));
    /*
      Read an image.
    */
    MagickWandGenesis();
    magick_wand=NewMagickWand();  
    status=MagickReadImage(magick_wand, (char *)imageFile);
    if (status == MagickFalse){
      ThrowWandException(magick_wand);
    }
    /*
      Turn the images into a thumbnail sequence.
    */
    MagickResetIterator(magick_wand);
    while (MagickNextImage(magick_wand) != MagickFalse)
      MagickRotateImage(magick_wand, bg, degree);
//    MagickSetImageCompression(magick_wand, MW_JPEGCompression);
//    MagickUnsharpMaskImage( magick_wand, 4.5, 4.0, 4.5, 0.02 );
    /*
      Write the image then destroy it.
    */
    status=MagickWriteImages(magick_wand, (char *)outputImage, MagickTrue);
    if (status == MagickFalse)
      ThrowWandException(magick_wand);
    magick_wand=DestroyMagickWand(magick_wand);
    MagickWandTerminus();
    return status;
}
Exemplo n.º 9
0
int magickModulateImage(const char *imageFile, const char *outputImage, double brightness, double saturation, double hue){
    MagickBooleanType status;

    MagickWand *magick_wand;

    /*
      Read an image.
    */
    MagickWandGenesis();
    magick_wand=NewMagickWand();  
    status=MagickReadImage(magick_wand, (char *)imageFile);
    if (status == MagickFalse){
      ThrowWandException(magick_wand);
    }
    /*
      Turn the images into a thumbnail sequence.
    */
    MagickResetIterator(magick_wand);
    while (MagickNextImage(magick_wand) != MagickFalse)
      MagickModulateImage(magick_wand, brightness, saturation, hue);
    /*
      Write the image then destroy it.
    */
    status=MagickWriteImages(magick_wand, (char *)outputImage, MagickTrue);
    if (status == MagickFalse)
      ThrowWandException(magick_wand);
    magick_wand=DestroyMagickWand(magick_wand);
    MagickWandTerminus();
    return status;
}
Exemplo n.º 10
0
/**
 * Helper function to provide a visual interpretation of the accumulator.
 */
void print_accumulator(char* name) {
	MagickWand *mw = NULL;
	PixelWand **pmw = NULL;
	PixelIterator *imw = NULL;
	MagickWandGenesis();

	unsigned long width, height;
	width = _circumference;
	height = _dimensions.semi_diagonal;

	mw = NewMagickWand();
	MagickSetSize(mw, width, height);
	MagickReadImage(mw, "xc:black");
    imw = NewPixelIterator(mw);

    int y, x;
    for (y=0; y<height; y++) {
    	pmw = PixelGetNextIteratorRow(imw, &width);
    	for (x=0; x< (long) width; x++) {
    		_CELL_TYPE* cell = &_accumulator[x][height-y-1];
    		PixelSetRed(pmw[x], 1.0/20.0 * cell->count);
    	}
    	PixelSyncIterator(imw);
    }
    MagickWriteImage(mw, name);

	if(mw)
		mw = DestroyMagickWand(mw);

	MagickWandTerminus();
}
Exemplo n.º 11
0
void iac_image_destroy(MagickWand *wand)
{

    if (wand)
        DestroyMagickWand(wand);

}
Exemplo n.º 12
0
int barcode_to_png (char *image_name) {
  MagickWand *magick_wand;
  MagickBooleanType status;

  int width, height, pad, half_pad;

  /* read a barcode image */
  MagickWandGenesis();
  magick_wand = NewMagickWand();
  MagickSetResolution(magick_wand, 300, 300);
  status = MagickReadImage(magick_wand, image_name);
  if (status == MagickFalse) ThrowWandException(magick_wand, 1);

  /* trim the image, resample it, and pad it by [10% of the long side] per side */
  MagickTrimImage(magick_wand, 10);
  width = MagickGetImageWidth(magick_wand);
  height = MagickGetImageHeight(magick_wand);
  pad = determine_padding(width, height);
  half_pad = round(pad/2);
  MagickExtentImage(magick_wand, width+pad, height+pad, -half_pad, -half_pad);
  
  /* write image (a PNG version and a formatted PS version) */
  status=MagickWriteImage(magick_wand, chop_path(image_name, ".png"));
  if (status == MagickFalse) ThrowWandException(magick_wand, 2);
  status=MagickWriteImage(magick_wand, chop_path(image_name, ".ps"));
  if (status == MagickFalse) ThrowWandException(magick_wand, 2);

  /* clean up */
  magick_wand=DestroyMagickWand(magick_wand);
  MagickWandTerminus();

  return 0;
}
Exemplo n.º 13
0
int main(int argc,char **argv)
{
	
	//creamos la imagen
	MagickWand *imagen, *imagen2;
	int proporcion = atoi(argv[3]);
	
	//inicializamos la imagen
	imagen = NewMagickWand();
	imagen2 = NewMagickWand();
	
	//cargamos la imagen
	MagickReadImage(imagen,argv[1]);
	
	//imagen2 = CloneMagickWand(imagen);

	//llamamos a la funcion de redimension
	Resize(imagen,imagen2,proporcion);
	
	//guardamos la imagen en disco
	MagickWriteImages(imagen2,argv[2],MagickTrue);
	
	//liberamos memoria destruyendo la imagen
	imagen = DestroyMagickWand(imagen2);
	
	//terminamos ejecucion de la libreria
	MagickWandTerminus();
	
	return 0;
}
static ngx_int_t
ngx_http_circle_gif_init(ngx_http_circle_gif_loc_conf_t *cglcf)
{
  u_int i;
  MagickWand *wand;
  PixelWand *bg_wand, *fg_wand;
  DrawingWand *dwand;

  wand = NewMagickWand();
  bg_wand = NewPixelWand();
  fg_wand = NewPixelWand();
  dwand = NewDrawingWand();
  if ((cglcf->circle_templates = malloc((1+radius2index(cglcf->max_radius, cglcf))*sizeof(unsigned char*))) == NULL ||
	  (cglcf->circle_sizes = malloc((1+radius2index(cglcf->max_radius, cglcf))*sizeof(size_t))) == NULL) {
    perror("malloc()");
    return NGX_ERROR;
  }
  for (i=0;i<=radius2index(cglcf->max_radius, cglcf);i++) {
    cglcf->circle_templates[i] = ngx_http_circle_gif_template(cglcf->min_radius+i*cglcf->step_radius, &cglcf->circle_sizes[i], 
            wand, bg_wand, fg_wand, dwand);
  }
  DestroyMagickWand( wand );
  DestroyPixelWand( fg_wand );
  DestroyPixelWand( bg_wand );
  DestroyDrawingWand( dwand );
  return i;
}
Exemplo n.º 15
0
G_MODULE_EXPORT void cb_image_save_cancel_clicked(GtkButton *button)
{
  if(camera_params.wand_data.saving_wand)
    DestroyMagickWand(camera_params.wand_data.saving_wand);
  camera_params.wand_data.saving_wand=NULL;
  gtk_widget_hide( camera_params.objects->imagesavedialog );
}
Exemplo n.º 16
0
uint64_t dhash_compute_filedesc(FILE* file, dhash_err* error) {
    MagickBooleanType status;
    MagickWand *magick_wand;

    magick_wand = NewMagickWand();
    status = MagickReadImageFile(magick_wand, file);
    if (status == MagickFalse) {
        set_mw_err(magick_wand, error);
        magick_wand = DestroyMagickWand(magick_wand);
        return 0;
    }
    uint64_t hash = dhash_compute_internal(magick_wand, error);
    magick_wand = DestroyMagickWand(magick_wand);

    return hash;
}
Exemplo n.º 17
0
gboolean magick_show_preview(struct data *data, 
                             struct image *image,
                             gint image_h)
{
    MagickWand *wand;
    struct image_size *img_size = NULL;
    const gchar *display;

    g_debug("in magick_show_preview");

    wand = _generate_webimage(data, image, image_h, &img_size);
    g_free(img_size);

    if (wand == NULL)
        return FALSE;

    gtk_window_iconify( GTK_WINDOW( data->top_window ) );
    while (g_main_context_iteration(NULL, FALSE));

    display = g_getenv("DISPLAY");
    MagickDisplayImage(wand, display ? display : ":0.0");

    DestroyMagickWand(wand);

    gtk_window_deiconify( GTK_WINDOW( data->top_window ) );
    while (g_main_context_iteration(NULL, FALSE));

    return TRUE;
}
Exemplo n.º 18
0
GmImp::~GmImp()
{
    if (this->wand != nullptr) {
        MagickResetIterator(this->wand);
        DestroyMagickWand(this->wand);
    }
}
Exemplo n.º 19
0
uint64_t dhash_compute_blob(const void* blob, const size_t length, dhash_err* error) {
    MagickBooleanType status;
    MagickWand *magick_wand;

    magick_wand = NewMagickWand();
    status = MagickReadImageBlob(magick_wand, blob, length);
    if (status == MagickFalse) {
        set_mw_err(magick_wand, error);
        magick_wand = DestroyMagickWand(magick_wand);
        return 0;
    }
    uint64_t hash = dhash_compute_internal(magick_wand, error);
    magick_wand = DestroyMagickWand(magick_wand);

    return hash;
}
Exemplo n.º 20
0
Arquivo: imgmin.c Projeto: dpq/imgmin
static void optimize_image(MagickWand *mw, const char *src, const char *dst,
                           size_t size_in, unsigned char *blob_in,
                           const struct imgmin_options *opt)
{
    MagickWand *tmp;
    size_t size_out = size_in + 1;

    report_before(mw, size_in);

#ifdef IMGMIN_STANDALONE
/*
 * NOTE: for now only allow use of external PNG tools in a standalone cmdline app,
 * not the built-in apache -- it's slower and less trustworthy.
 */
    if (strcmp("-", src) && !strcmp("PNG", MagickGetImageFormat(mw)))
    {
        do_png(mw, src, dst, opt);
        return;
    } else {
#endif
        tmp = search_quality(mw, dst, opt);
#ifdef IMGMIN_STANDALONE
    }
#endif

    size_out = blob_write(blob_in, size_in, tmp, dst);
    report_after(tmp, size_in, size_out);
    DestroyMagickWand(tmp);
}
Exemplo n.º 21
0
int main(int argc, char* argv[]) {
	MagickWand *mw = NULL;
	DrawingWand *dw = NULL;
	PixelWand *fill = NULL;
	int x,y;

	MagickWandGenesis();
	mw = NewMagickWand();
	MagickReadImage(mw,"logo:");

	fill = NewPixelWand();
	dw = NewDrawingWand();
	PixelSetColor(fill,"green");
	DrawSetFillColor(dw,fill);
	for (x=200;x<210;x++)
		for (y=100;y<110;y++)
			DrawPoint(dw,x,y);
	

	MagickDrawImage(mw,dw);


	MagickWriteImage(mw,"logo.jpg");

	if (dw) dw = DestroyDrawingWand(dw);
	if (fill) fill = DestroyPixelWand(fill);
	if (mw) mw = DestroyMagickWand(mw);
	MagickWandTerminus();
}
Exemplo n.º 22
0
void
img_destroy (img_t *im)
{
	if (im) {
		if (im->banner) {
			im->banner = (void *) DestroyMagickWand((MagickWand *) im->banner);
		}
		im->banner = NULL;

		if (im->screen) {
			im->screen = (void *) DestroyMagickWand((MagickWand *) im->screen);
		}
		im->screen = NULL;
	}

	MagickWandTerminus();
}
Exemplo n.º 23
0
ARUint8* loadImage(char* filename, int* xsize, int* ysize)
{
	ARUint8 *dptr;
	
	Image *image;
	MagickWand* magick_wand;

	magick_wand=NewMagickWand(); 
    if( magick_wand == NULL) {
        fprintf(stderr, "bad magickwand\n");
    }

	MagickBooleanType status=MagickReadImage(magick_wand,filename);
	if (status == MagickFalse) {
		//fprintf(stderr, "%s can't be read\n", filename);
		//exit(1);
        //return; //(1);
		ThrowWandException(magick_wand);
	}

	image = GetImageFromMagickWand(magick_wand);

	//ContrastImage(image,MagickTrue); 
	//EnhanceImage(image,&image->exception); 

	int index;

	*xsize = image->columns;
	*ysize = image->rows;
		
	dptr = malloc(sizeof(ARUint8) * 3 * image->rows * *xsize);
	int y;
	index = 0;
	for (y=0; y < (long) image->rows; y++)
	{
		const PixelPacket *p = AcquireImagePixels(image,0,y,*xsize,1,&image->exception);
		if (p == (const PixelPacket *) NULL)
			break;
		int x;
		for (x=0; x < (long) *xsize; x++)
		{
			/// convert to ARUint8 dptr
			/// probably a faster way to give the data straight over
			/// in BGR format
			dptr[index*3+2]   = p->red/256;
			dptr[index*3+1] = p->green/256;
			dptr[index*3] = p->blue/256;
			
			//fprintf(stderr,"%d, %d, %d\t%d\t%d\n", x, y, p->red/256, p->green/256, p->blue/256);
			p++;
			index++;
		}
	}

    DestroyMagickWand(magick_wand);

	return dptr;
}
Exemplo n.º 24
0
Arquivo: zimg.c Projeto: Codefor/zimg
char* get_phone_img(const char *phone_str, size_t *img_size){
    if(phone_str == NULL){
	return NULL;
    }

    MagickWand *m_wand  = NULL;
    PixelWand *p_wand  = NULL;
    DrawingWand *d_wand = NULL;


    /* Create a wand */
    m_wand = NewMagickWand();
    p_wand = NewPixelWand();
    d_wand = NewDrawingWand();

    PixelSetColor(p_wand,"white");

    int height = 18;
    int width = strlen(phone_str) * 130 / 12;

    MagickNewImage(m_wand, width,height ,p_wand);

    //draw number
    PixelSetColor(p_wand,"black");
    DrawSetFillColor(d_wand,p_wand);
    DrawSetFont (d_wand, "Arial" ) ;
    DrawSetFontSize(d_wand,20);
    DrawSetStrokeColor(d_wand,p_wand);
    DrawAnnotation(d_wand,0,height -2,phone_str);
    MagickDrawImage(m_wand,d_wand);
    //MagickTrimImage(m_wand,0);
    //ImageFormat MUST be SET,otherwise,otherwise we will not MagickGetImageBlob properly
    MagickSetImageFormat(m_wand,"JPEG");

    char *p = NULL;
    char *data = NULL;

    p = (char *)MagickGetImageBlob(m_wand,img_size);

    if(p != NULL){
	data = (char *)malloc(*img_size);
	if(data != NULL){
	    memcpy(data,p,*img_size);
	}else{
	    LOG_PRINT(LOG_INFO, "malloc Failed!");
	}
    }else{
	LOG_PRINT(LOG_INFO, "MagickGetImageBlob Failed!");
    }
    
    /* Tidy up */
    MagickRelinquishMemory(p);
    DestroyMagickWand(m_wand);
    DestroyPixelWand(p_wand);

    return data;
}
Exemplo n.º 25
0
caddr_t bif_im_DeepZoom4to1 (caddr_t * qst, caddr_t * err, state_slot_t ** args)
  {
  im_env_t env;
  caddr_t res;
  int fmt_is_set = 0;
  int image_ctr;
  im_init (&env, qst, args, "IM DeepZoom4to1");
  im_set_background (&env, "#000000");
  env.ime_target_magick_wand = NewMagickWand ();
  if (MagickFalse == MagickNewImage (env.ime_target_magick_wand, 256, 256, env.ime_background))
    im_leave_with_error (&env, "22023", "IM001", "Can not make new image");
  if (MagickFalse == MagickSetImageType (env.ime_target_magick_wand, TrueColorType))
    im_leave_with_error (&env, "22023", "IM001", "Can not set image type");
  if (MagickFalse == MagickSetImageDepth (env.ime_target_magick_wand, 16))
    im_leave_with_error (&env, "22023", "IM001", "Can not set image depth");
  if (MagickFalse == MagickSetImageExtent (env.ime_target_magick_wand, 256, 256))
    im_leave_with_error (&env, "22023", "IM001", "Can not set image extent");
  if (MagickFalse == MagickSetImageBackgroundColor (env.ime_target_magick_wand, env.ime_background))
    im_leave_with_error (&env, "22023", "IM001", "Can not set image background");
  image_ctr = BOX_ELEMENTS (args) / 2;
  if (image_ctr > 4)
    image_ctr = 4;
  while (0 < image_ctr--)
    {
      if (DV_DB_NULL == DV_TYPE_OF (bif_arg (qst, args, image_ctr*2, "IM DeepZoom4to1")))
        continue;
      im_env_set_input_blob (&env, image_ctr * 2);
      /*im_env_set_blob_ext (&env, 2);*/
      im_read (&env);
      MagickResetIterator (env.ime_magick_wand);
      while (MagickNextImage (env.ime_magick_wand) != MagickFalse)
        {
          unsigned long v_size, h_size;
          if (!fmt_is_set)
            {
              if (MagickFalse == MagickSetImageFormat (env.ime_target_magick_wand, MagickGetImageFormat (env.ime_magick_wand)))
                im_leave_with_error (&env, "22023", "IM001", "Can not set image format");
              fmt_is_set = 1;
            }
          h_size = MagickGetImageWidth (env.ime_magick_wand);
          v_size = MagickGetImageHeight (env.ime_magick_wand);
          if ((256 < h_size) || (256 < v_size))
            continue;
          MagickResizeImage (env.ime_magick_wand, h_size/2, v_size/2, BoxFilter, 1.0);
          if (MagickFalse == MagickCompositeImage (env.ime_target_magick_wand, env.ime_magick_wand, OverCompositeOp, (image_ctr & 1) * 128, (image_ctr & 2) * 64))
            im_leave_with_error (&env, "22023", "IM001", "Can not composite image");
        }
      im_reset_read (&env);
    }
  MagickProfileImage (env.ime_target_magick_wand, "*", NULL, 0);
  DestroyMagickWand (env.ime_magick_wand);
  env.ime_magick_wand = env.ime_target_magick_wand;
  env.ime_target_magick_wand = NULL;
  res = im_write (&env);
  im_leave (&env);
  return res;
}
Exemplo n.º 26
0
int main(int argc,char **argv)
{
  char
    filename[MaxTextExtent];

  MagickBooleanType
    status;

  MagickWand
    *canvas;

  if (argc != 2)
    {
      (void) printf ("Usage: %s filename\n",argv[0]);
      exit(1);
    }
  (void) CopyMagickString(filename,argv[1],MaxTextExtent);
  /*
    Create canvas image.
  */
  MagickWandGenesis();
  canvas=NewMagickWand();
  status=MagickSetSize(canvas,596,842);
  if (status == MagickFalse)
    ThrowWandException(canvas);
  status=MagickReadImage(canvas,"xc:white");
  if (status == MagickFalse)
    ThrowWandException(canvas);
  /*
    Scribble on image.
  */
  status=ScribbleImage(canvas);
  if (status == MagickFalse)
    ThrowWandException(canvas);
  /*
    Set pixel depth to 8.
  */
  status=MagickSetImageDepth(canvas,8);
  if (status == MagickFalse)
    ThrowWandException(canvas);
  /*
    Set output as RLE compressed.
  */
  status=MagickSetImageCompression(canvas,RLECompression);
  if (status == MagickFalse)
    ThrowWandException(canvas);
  /*
    Save image to file.
  */
  status=MagickWriteImage(canvas,filename);
  if (status == MagickFalse)
    ThrowWandException(canvas);
  canvas=DestroyMagickWand(canvas);
  MagickWandTerminus();
  return(0);
}
Exemplo n.º 27
0
/**
 * deinitialize ImageMagick
 */
void im_deinit(struct Ledcat *c)
{
#if HAVE_MAGICKWAND == 1
    if(!c->raw)
    {
        DestroyMagickWand(c->mw);
        MagickWandTerminus();
    }
#endif
}
Exemplo n.º 28
0
 virtual ~eim_image()
 {
     if(background_ != NULL)
     {
         DestroyPixelWand(background_);
     }
     MagickClearException(magick_wand);
     magick_wand=DestroyMagickWand(magick_wand);
     MagickWandTerminus();
 }
Exemplo n.º 29
0
void main(void)
{
	clock_t begin, end;
	double time_spent;
	double imageAspectRatio = 0;
	double originalWidth;
	double originalHeight;
	double masterAspectRatio = 1.77; 

	MagickWand *m_wand = NULL;
	
	int width,height;
	
	MagickWandGenesis();
	
	m_wand = NewMagickWand();

	MagickReadImage(m_wand,"mona-lisa.JPG");
	begin = clock();	
	
	originalWidth = MagickGetImageWidth(m_wand);
	originalHeight = MagickGetImageHeight(m_wand);
	
	imageAspectRatio = originalWidth/originalHeight;
	if(imageAspectRatio <= masterAspectRatio)
	{

		MagickCropImage(m_wand,originalWidth,(int)(originalWidth/masterAspectRatio),0,(originalHeight-(int)(originalWidth/masterAspectRatio))/2 );
		printf("%d X %d ",MagickGetImageWidth(m_wand) , MagickGetImageHeight(m_wand));
	}
	else
	{
		MagickCropImage(m_wand,(int)(originalHeight * masterAspectRatio),originalHeight,(originalWidth - (int)(originalHeight * masterAspectRatio))/2,0);
	}
	if (originalWidth > 1920)
		MagickResizeImage(m_wand,1920,1080,LanczosFilter,1);
	

	end = clock();
	time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
	printf("Time taken is %f\n",time_spent);

	
//	MagickCropImage(m_wand,originalWidth/2,originalHeight/2,0,0);
	// Set the compression quality to 95 (high quality = low compression)
	//MagickSetImageCompressionQuality(m_wand,95);
	
	/* Write the new image */
	MagickWriteImage(m_wand,"master.jpg");
	
	/* Clean up */
	if(m_wand)m_wand = DestroyMagickWand(m_wand);
	
	MagickWandTerminus();}
Exemplo n.º 30
0
gboolean magick_make_webimage(struct data *data, 
                              struct image *image,
                              const gchar *uri,
                              gint image_h)
{
    MagickWand *wand;
    struct image_size *img_size = NULL;
    GnomeVFSResult result;
    GnomeVFSFileInfo *info;

    g_debug("in magick_make_webimage");

    wand = _generate_webimage(data, image, image_h, &img_size);
    if (wand == NULL) 
        return FALSE;

    /* save the image to a file */
    if (!_save(data, wand, uri)) {
        DestroyMagickWand(wand);
        g_free(img_size);
        return FALSE;
    }
    
    DestroyMagickWand(wand);

    /* get file size */
    info = gnome_vfs_file_info_new();
    result = gnome_vfs_get_file_info(uri, info,
                                     GNOME_VFS_FILE_INFO_DEFAULT | 
                                     GNOME_VFS_FILE_INFO_FOLLOW_LINKS);
    if (result == GNOME_VFS_OK) {
        img_size->size = info->size / 1024;
    } else {
        img_size->size = 0;
    }
    
    image->sizes = g_slist_append(image->sizes, img_size);
    gnome_vfs_file_info_unref(info);

    return TRUE;
}