write multiple images for loop

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
gabrielpasv
Posts: 3
Joined: 2013-11-01T04:30:23-07:00
Authentication code: 6789

write multiple images for loop

Post by gabrielpasv » 2013-11-01T04:34:39-07:00

I am working with Magick++ API on linux and I am reading multiple images, processing them in for loop and then I need to write them in the for loop as well passing the index value "i" to the filename. However I don't use sprintf, I use the method from Magick++ which is image.write();

How can do it ? See part of my code:

Code: Select all

int main(int argc, char **argv) {

// ImageMagick Stuffs

	InitializeMagick(*argv);

	vector<Blob> myblob;
	vector<Image> imageList(7);
	imageList[0].read("/cars/placa1/2.png");
	imageList[1].read("/cars/placa1/4.png");
	imageList[2].read("/cars/placa1/9.png");
	imageList[3].read("/cars/placa1/9_.png");
	imageList[4].read("/cars/placa1/e.png");
	imageList[5].read("/cars/placa1/b.png");
	imageList[6].read("/cars/placa1/g.png");


	for (unsigned int i = 0;  i <= imageList.size() ; ++i) {
		imageList[i].resize("30x50");
//		imageList[i].write("/cars/results/%d.png");
		imageList[i].write(&myblob[i]);
	}

I saw another post regarding this but none one was answered. I am new here, if someone could help me. Thank you

gabrielpasv
Posts: 3
Joined: 2013-11-01T04:30:23-07:00
Authentication code: 6789

Re: write multiple images for loop

Post by gabrielpasv » 2013-11-01T09:18:30-07:00

I got my problem solved. Whoever is interested here is part of the code

Code: Select all

int main(int argc, char **argv) {

// ImageMagick Stuffs

	InitializeMagick(*argv);

//	vector<Blob> myblob(7);
	vector<Image> imageList(7);
	imageList[0].read("/cars/placa1/2.png");
	imageList[1].read("/cars/placa1/4.png");
	imageList[2].read("/cars/placa1/9.png");
	imageList[3].read("/cars/placa1/9_.png");
	imageList[4].read("/cars/placa1/e.png");
	imageList[5].read("/cars/placa1/b.png");
	imageList[6].read("/cars/placa1/g.png");


	for (unsigned int i = 0;  i < imageList.size() ; i++) {
		imageList[i].resize("30x50");
		char filename[100];
		snprintf(filename, sizeof filename, "/cars/results/%d.png", i);
		imageList[i].write(filename);

	}

Post Reply