Beispiel #1
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;
}
Beispiel #2
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;
}
Beispiel #3
0
int main(int argc, char *argv[]) {
	int compare_size = COMPARE_SIZE;
	unsigned int maxerr = COMPARE_THRESHOLD;
	if (argc < 3) {
		fprintf(stdout, "\nERROR: Not enough arguments\n");
		usage();
		exit(1);
	}
	char *sql_info = argv[1];
	int portno = atoi(argv[2]);
	if (!portno) {
		fprintf(stdout, "\nERROR: Invalid port\n");
		usage();
		exit(1);
	}

	// Work out how many CPUs we have. Default to 2
	global_cpu_count = get_cpu_count(stdout);
	if (global_cpu_count == 0) {
		global_cpu_count = 2;
	}

	MagickWandGenesis();

	server_loop(stdout, sql_info, portno, compare_size, maxerr);

	MagickWandTerminus();

	/* The final thing that main() should do */
	pthread_exit(NULL);

	exit(0);
}
Beispiel #4
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;
}
Beispiel #5
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;
}
Beispiel #6
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;
    
}
Beispiel #7
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;
}
Beispiel #8
0
int main(int argc,char **argv) {
	MagickWand *magick_wand;
	MagickBooleanType status;

	MagickWandGenesis();
	magick_wand = NewMagickWand();

	//This is a color image
	status = MagickReadImage(magick_wand, "./Biter_500.jpg");

	MagickScaleImage(magick_wand, 16, 16);

//	MagickQuantizeImage(
//		magick_wand,
//		//Changing to 255 makes the image change to grayscale
//		255,
//		GRAYColorspace,
//		0,
//		0,
//		0
//	);

	status = MagickWriteImages(magick_wand, "./67258.jpg", MagickTrue);
	MagickWandTerminus();
 
    return(0);
}
Beispiel #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;
}
Beispiel #10
0
int main(int argc,char **argv) {
    MagickWand *magick_wand_background;
    MagickWand *magick_wand_foreground;
    MagickWandGenesis();
    
    magick_wand_background = NewMagickWand();
    magick_wand_foreground = NewMagickWand();

    MagickReadImage(magick_wand_background, "magick:logo");
    MagickReadImage(magick_wand_foreground, "magick:rose");
 
    MagickSetGravity(magick_wand_background, CenterGravity);
    MagickSetGravity(magick_wand_foreground, CenterGravity);
 
    MagickCompositeImage(
        magick_wand_background,
        magick_wand_foreground,
        AtopCompositeOp,
        0, 0
    );
    
    MagickSetFormat(magick_wand_background, "png");

    MagickWriteImage(magick_wand_background, "./output/gravity.png");
    MagickWandTerminus();

    return 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();
}
Beispiel #12
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();
}
Beispiel #13
0
int main(int argc,char **argv) {
    MagickWand *magick_wand;
    MagickBooleanType status;

    MagickWandGenesis();
    magick_wand = NewMagickWand();

    MagickSetResourceLimit(MemoryResource, 1000 * 1000);
    MagickSetResourceLimit(DiskResource, 1000 * 1000);
    

    status = MagickReadImage(magick_wand, "./images/picture-100M-6000x6000.png");

    if (status == MagickFalse) {
        printf("Failed to MagickReadImage");
        return -1;
    }

    printf("This shouldn't be reached - the image is larger than the area resource.\n");

    MagickSetImageFormat(magick_wand, "png");

    status = MagickWriteImages(magick_wand, "./output/resource_output.png", MagickTrue);
    if (status == MagickFalse) {
        printf("Failed to MagickWriteImages");
        return -1;
    }

    MagickWandTerminus();
 
    return(0);
}
Beispiel #14
0
void *libInit( void *sb )
{
	struct ImageLibrary *l = NULL;
	DEBUG("IMAGE LIBRARY INIT\n");

	if( ( l = calloc( 1, sizeof( struct ImageLibrary ) ) ) == NULL )
		return NULL;

	l->l_Name = LIB_NAME;
	l->l_Version = LIB_VERSION;
	l->libClose           = dlsym( l->l_Handle, "libClose");
	l->GetVersion         = dlsym( l->l_Handle, "GetVersion");
	l->GetRevision        = dlsym( l->l_Handle, "GetRevision");

	// user.library structure
	l->ResizeImage               = dlsym( l->l_Handle, "FResizeImage");
	l->ImageRead               = dlsym( l->l_Handle, "ImageRead");
	l->ImageWrite               = dlsym( l->l_Handle, "ImageWrite");
	
	l->sb = sb;

#ifdef USE_IMAGE_MAGICK
	MagickWandGenesis();
#endif

	return ( void *)l;
}
Beispiel #15
0
static PyObject *
im_InitMagick(PyObject *self, PyObject *args) {

	MagickWandGenesis();

	Py_INCREF(Py_None);
	return Py_None;
}
Beispiel #16
0
ARUint8* loadImage(char* filename, int* xsize, int* ysize)
{
	ARUint8 *dptr;
	
	Image *image;
	MagickWand* magick_wand;

	MagickWandGenesis();
	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++;
		}
	}

	return dptr;
}
Beispiel #17
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);
}
bool ImageMagickGIFEncoderOpen(struct ImageMagickGIFEncoder* encoder, const char* outfile) {
	MagickWandGenesis();
	encoder->wand = NewMagickWand();
	MagickSetImageFormat(encoder->wand, "GIF");
	MagickSetImageDispose(encoder->wand, PreviousDispose);
	encoder->outfile = strdup(outfile);
	encoder->frame = malloc(VIDEO_HORIZONTAL_PIXELS * VIDEO_VERTICAL_PIXELS * 4);
	encoder->currentFrame = 0;
	return true;
}
Beispiel #19
0
void register_fuppes_plugin(plugin_info* info)
{
	strcpy(info->plugin_name, "magickWand");
	strcpy(info->plugin_author, "Ulrich Voelkel");
	info->plugin_type = PT_TRANSCODER;
	
	//#ifdef WIN32
	MagickWandGenesis();
	//#endif
}
Beispiel #20
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();}
Beispiel #21
0
bool
img_init (img_t *im)
{
	MagickWandGenesis();

	if (im) {
		im->screen = (void *) NewMagickWand();
		im->banner = (void *) NewMagickWand();
		return true;
	}

	return false;
}
int main (int argc, const char *argv[])
{
  // option pre-scan
  int quiet = 0;
  int display = 1;
  
  MagickWandGenesis();
  
  processor = zbar_processor_create(0);
  assert(processor);
  if(zbar_processor_init(processor, NULL, display)) 
  {
    zbar_processor_error_spew(processor, 0);
    return(1);
  }
  
  if(display)
    zbar_processor_set_visible(processor, 1);    
  
  IplImage * image = cvLoadImage(argv[1], CV_LOAD_IMAGE_GRAYSCALE);
  
  if(scan_image(image))
    return (exit_code);
  
  if(num_images && !quiet && xmllvl <= 0) 
  {
    fprintf(stderr, "scanned %d barcode symbols from %d images",
            num_symbols, num_images);
#ifdef HAVE_SYS_TIMES_H
#ifdef HAVE_UNISTD_H
    long clk_tck = sysconf(_SC_CLK_TCK);
    struct tms tms;
    if(clk_tck > 0 && times(&tms) >= 0) 
    {
      double secs = tms.tms_utime + tms.tms_stime;
      secs /= clk_tck;
      fprintf(stderr, " in %.2g seconds\n", secs);
    }
#endif
#endif
    fprintf(stderr, "\n");
    if(notfound)
      fprintf(stderr, "%s", warning_not_found);
  }
  if(num_images && notfound && !exit_code)
    exit_code = 4;
  
  zbar_processor_destroy(processor);
  MagickWandTerminus();
  return(exit_code);
}
Beispiel #23
0
int main(int argc, char **argv){
    if (argc != 4){
        (void) fprintf(stdout,"Usage: %s palette input-file output-file\n",argv[0]);
        exit(0);
    }
    read_palette(argv[1]);
    print_palette();
    
    char *description;
    ExceptionType severity;


    #define ThrowWandException(wand) \
    { \
        description=MagickGetException(wand,&severity); \
        (void) fprintf(stderr,"%s %s %lu %s\n",GetMagickModule(),description); \
        description=(char *) MagickRelinquishMemory(description); \
        exit(-1); \
    }

    MagickBooleanType status;
    MagickPixelPacket pixel;
    MagickWand *wand;
    WandView *view;
    /*
       Read an image.
       */
    MagickWandGenesis();
    wand = NewMagickWand();
    status = MagickReadImage(wand, argv[2]);
    if (status == MagickFalse) ThrowWandException(wand);

    /*
       Sigmoidal non-linearity contrast control.
       */
    view = NewWandView(wand);
    if (view == (WandView *) NULL) ThrowWandException(wand);
    status = UpdateWandViewIterator(view, recolor, (void *)NULL);
    if (status == MagickFalse) ThrowWandException(wand);
    view = DestroyWandView(view);

    /*
       Write the image then destroy it.
       */
    status = MagickWriteImages(wand, argv[3], MagickTrue);
    if (status == MagickFalse) ThrowWandException(wand);
    wand = DestroyMagickWand(wand);
    MagickWandTerminus();

    return 0;
}
/**
 * Prints count lines on output with background bg. Lines can be scaled by using factor.
 * NOTE: This performs some filtering removing lines passing through origin
 */
void print_lines(char* output, char* bg, LINE_TYPE* lines, sizep_t count, double factor) {
	MagickWand *mw = NULL;
	DrawingWand *dw = NULL;
	PixelWand *pmw = NULL;
	unsigned long width, semi_width, height, semi_height;

	MagickWandGenesis();
	mw = NewMagickWand();
	dw = NewDrawingWand();
	pmw = NewPixelWand();

	MagickReadImage(mw, bg);
	width = MagickGetImageWidth(mw);
	semi_width = ceil(width/2.0);
	height = MagickGetImageHeight(mw);
	semi_height = ceil(height/2.0);
	PixelSetColor(pmw,"red");
	DrawSetStrokeColor(dw, pmw);
	DrawSetStrokeWidth(dw, .5*factor);
	DrawSetStrokeAntialias(dw, 0);

	sizep_t n;
	for(n=0; n<count; n++) {
		LINE_TYPE cline = lines[n];

		double m = -cos(cline.t)/sin(cline.t);
		double b = cline.r/sin(cline.t);

		if ((-0.5 < m && m < 0.5) || (-1 < b && b < 1)) continue; // remove lines too horizontal

		double x0 = - ((long) semi_width); double y0 = x0*m+b;
		double x1 = ((long) semi_width); double y1 = x1*m+b;

		// Apply factor
		x0 *= factor; y0 *= factor; x1 *= factor; y1 *= factor;

		// Fix coordinates and plot over the image
		DrawLine(dw, x0+semi_width, height-y0-semi_height, x1+semi_width, height-y1-semi_height);
	}

	MagickDrawImage(mw,dw);
	MagickWriteImage(mw, output);

	pmw = DestroyPixelWand(pmw);
	mw = DestroyMagickWand(mw);
	dw = DestroyDrawingWand(dw);

	MagickWandTerminus();
}
Beispiel #25
0
/**
 * initialize ImageMagick
 */
NftResult im_init(struct Ledcat *c)
{
#if HAVE_IMAGEMAGICK == 1
    /* initialize magickWand */
    if(!c->raw)
    {
        MagickWandGenesis();
        if(!(c->mw = NewMagickWand()))
            return FALSE;


    }
#endif
    return TRUE;
}
Beispiel #26
0
int main (int argc,char **argv)
 {
	FILE *fp;
	unsigned char *polje;
	char format[5] = {0};
	int len;
	size_t width, height;

	MagickWand	*image_wand;
	MagickBooleanType status;


	//ucitavanje slike
	if( (fp = fopen(argv[1],"rb")) == NULL)
		printf("nemoze otvorit sliku\n");

	fseek(fp,0,SEEK_END);
	len = ftell(fp);
	fseek(fp,0,SEEK_SET);

	polje = (unsigned char*) malloc (len);
	fread(polje,1,len,fp);

	//ucitavanje u imagemagick

	MagickWandGenesis();
	image_wand = NewMagickWand();

	status = MagickReadImageBlob(image_wand, polje, len);
	
	free(polje);
	if (status == MagickFalse)
					{printf("\nnevalja status\n"); exit(-1);}

	strcpy(format,MagickGetImageFormat(image_wand));
	width = MagickGetImageWidth(image_wand);
	height = MagickGetImageHeight(image_wand);

	printf("width = %d\nheight = %d\nformat = %s\n",width,height,format);

	fclose(fp);

	image_wand = DestroyMagickWand(image_wand); 
	MagickWandTerminus();

	system("pause");
    return 0;
 }
Beispiel #27
0
void im_connect (void *appdata)
{
  im_IMVERSION = box_dv_short_string (IM_VERSION);
  im_lib_mutex = mutex_allocate ();

  bif_define ("IM ResizeImageFile", bif_im_ResizeImageFile);
  bif_define ("IM ThumbnailImageFile", bif_im_ThumbnailImageFile);
  bif_define ("IM ConvertImageFile", bif_im_ConvertImageFile);
  bif_define ("IM ResampleImageFile", bif_im_ResampleImageFile);
  bif_define ("IM RotateImageFile", bif_im_RotateImageFile);
  bif_define ("IM CropImageFile", bif_im_CropImageFile);
  bif_define ("IM GetImageFileAttribute", bif_im_GetImageFileAttribute);
  bif_define ("IM GetImageFileFormat", bif_im_GetImageFileFormat);
  bif_define ("IM GetImageFileIdentify", bif_im_GetImageFileIdentify);
  bif_define ("IM GetImageBlobIdentify", bif_im_GetImageBlobIdentify);

  bif_define ("IM GetImageFileWidth", bif_im_GetImageFileWidth);
  bif_define ("IM GetImageFileHeight", bif_im_GetImageFileHeight);
  bif_define ("IM GetImageFileDepth", bif_im_GetImageFileDepth);
  bif_define ("IM GetImageFileWH", bif_im_GetImageFileWH);

  bif_define ("IM ResizeImageFileToBlob", bif_im_ResizeImageFileToBlob);
  bif_define ("IM ThumbnailImageFileToBlob", bif_im_ThumbnailImageFileToBlob);
  bif_define ("IM ResampleImageFileToBlob", bif_im_ResampleImageFileToBlob);
  bif_define ("IM RotateImageFileToBlob", bif_im_RotateImageFileToBlob);
  bif_define ("IM CropImageFileToBlob", bif_im_CropImageFileToBlob);
  bif_define ("IM GetImageBlobAttribute", bif_im_GetImageBlobAttribute);
  bif_define ("IM GetImageBlobFormat", bif_im_GetImageBlobFormat);
  bif_define ("IM GetImageBlobWidth", bif_im_GetImageBlobWidth);
  bif_define ("IM GetImageBlobHeight", bif_im_GetImageBlobHeight);
  bif_define ("IM GetImageBlobDepth", bif_im_GetImageBlobDepth);
  bif_define ("IM GetImageBlobWH", bif_im_GetImageBlobWH);

  bif_define ("IM ConvertImageBlob", bif_im_ConvertImageBlob);
  bif_define ("IM ResizeImageBlob", bif_im_ResizeImageBlob);
  bif_define ("IM ThumbnailImageBlob", bif_im_ThumbnailImageBlob);
  bif_define ("IM DeepZoom4to1", bif_im_DeepZoom4to1);
  bif_define ("IM ResampleImageBlob", bif_im_ResampleImageBlob);
  bif_define ("IM RotateImageBlob", bif_im_RotateImageBlob);
  bif_define ("IM CropImageBlob", bif_im_CropImageBlob);
  bif_define ("IM CropAndResizeImageBlob", bif_im_CropAndResizeImageBlob);
#if defined(HasTTF) || defined(HasFREETYPE)
  bif_define ("IM AnnotateImageBlob", bif_im_AnnotateImageBlob);
#endif
  bif_define ("IM CreateImageBlob", bif_im_CreateImageBlob);
  bif_define ("IM XYtoMorton", bif_im_XY_to_Morton);
  MagickWandGenesis();
}
Beispiel #28
0
void saveImage(char* input,char* output)
{
        printf("save-Image\n");
        MagickWand *m_wand = NULL;
        MagickWandGenesis();
        m_wand = NewMagickWand();
        //open
        MagickReadImage(m_wand,input);
        //save
        MagickWriteImage(m_wand,output);

        /* Clean up */
        if(m_wand)m_wand = DestroyMagickWand(m_wand);

        MagickWandTerminus();
}
/**
 * Extracts from a binary image white points and consider them as information
 * filling sample array and setting size structure.
 *
 * NOTE: When extracting points origin is moved to the center of the image:
 *
 *                     +semi_height
 *     Image Origin
 *              +-----------|
 *              |           |
 *              |           |
 *              |           | Hough Origin
 *  -semi_width ------------+------------- +semi_width
 *                          |
 *                          |
 *                          |
 *                          |
 *
 *                     -semi_height
 */
sizep_t get_points(char* name, POINT_TYPE **sample, SIZE_TYPE *size) {
	MagickWand *mw = NULL;
	PixelWand **pmw = NULL;
	PixelIterator *imw = NULL;
	MagickWandGenesis();

	mw = NewMagickWand();
	MagickReadImage(mw, name);

	unsigned long width, semi_width, height, semi_height;
    width = MagickGetImageWidth(mw);
    semi_width = ceil(width/2.0);
    height = MagickGetImageHeight(mw);
    semi_height = ceil(height/2.0);
    imw = NewPixelIterator(mw);

    sizep_t count = 0;
    POINT_TYPE *aux = (POINT_TYPE*) malloc(sizeof(POINT_TYPE)*width*height);

    // Extract white points
    int y, x;
    for (y=0; y<height; y++) {
    	pmw = PixelGetNextIteratorRow(imw, &width);
    	for (x=0; x< (long) width; x++) {
    		if (PixelGetBlack(pmw[x])) {
    			aux[count].x = x-semi_width;
    			aux[count].y = (height-y)-semi_height;
    			count++;
    		}
    	}
    }

	POINT_TYPE* output = (POINT_TYPE*) malloc(sizeof(POINT_TYPE)*count);
	memcpy(output, aux, sizeof(POINT_TYPE)*count);
	free(aux); aux = NULL;

	if(mw)
		mw = DestroyMagickWand(mw);

	MagickWandTerminus();

	(*sample) = output;
	size->width = width;
	size->height = height;
	return count;
}
Beispiel #30
0
int main(int argc, char *argv[])
{
	MagickWand *wand = NULL;
	MagickBooleanType ret;
	char *description;
	ExceptionType excep;

	if (argc < 2) {
		fprintf(stderr, "Usage: %s file\n", argv[0]);
		return 1;
	}

	MagickWandGenesis();

	wand = NewMagickWand();
	if (wand == NULL) {
		description = MagickGetException(wand, &excep);
		fprintf(stderr, "%s; %s\n", "NewMagickWand() failed", description);
		MagickRelinquishMemory(description);
		return 1;
	}

	ret = MagickReadImage(wand, argv[1]);
	if (ret != MagickTrue) {
		description = MagickGetException(wand, &excep);
		fprintf(stderr, "%s; %s\n", "MagickReadImage() failed", description);
		MagickRelinquishMemory(description);
		return 1;
	}

	printf("Format: %s\n", MagickGetImageFormat(wand));
	printf("Filename: %s\n", MagickGetImageFilename(wand));
	printf("Compression Quality: %ld\n", MagickGetCompressionQuality(wand));
	printf("Signature: %s\n", MagickGetImageSignature(wand));
	printf("Width: %ld\n", MagickGetImageWidth(wand));
	printf("Height: %ld\n", MagickGetImageHeight(wand));

	if (wand != NULL) {
		DestroyMagickWand(wand);
	}

	MagickWandTerminus();

	return 0;
}