Hi,
I have a project that need to merge a few tiles in one image. I use MagickMontageImage and the order of the tiles does not follow the read in order, while the command line tool of Montage works with the tile read in order. Any help or suggestion? Thanks
The sample code is as follows:
int main(int argc,char **argv)
{
MagickBooleanType status;
MagickWand *tile, *image, *int_image;
DrawingWand *d_wand;
MagickWandGenesis();
image=NewMagickWand();
status=MagickReadImage(image,"1.png");
status=MagickReadImage(image,"2.png");
status=MagickReadImage(image,"3.png");
status=MagickReadImage(image,"4.png");
status=MagickReadImage(image,"5.png");
status=MagickReadImage(image,"6.png");
status=MagickReadImage(image,"7.png");
status=MagickReadImage(image,"8.png");
status=MagickReadImage(image,"9.png");
PixelWand *p_wand;
p_wand = NewPixelWand();
PixelSetColor(p_wand,"none");
d_wand = NewDrawingWand();
char geo[10];
memset(geo, '\0', sizeof(geo));
sprintf(geo, "3x3+0+0");
int_image = MagickMontageImage(image, d_wand, geo,"50x50+0+0",ConcatenateMode,"0x0+0+0");
image=DestroyMagickWand(image);
d_wand = DestroyDrawingWand(d_wand);
p_wand = DestroyPixelWand(p_wand);
int_image=DestroyMagickWand(int_image);
MagickWandTerminus();
return(0);
}
image order in MagickMontageImage
image order in MagickMontageImage
Last edited by mlin@pelmorex.com on 2010-09-01T10:47:11-07:00, edited 1 time in total.
Re: image order in MagickMontageImage
also I saw memory leak in the function:
==18347== 428 bytes in 18 blocks are definitely lost in loss record 20 of 34
==18347== at 0x4A05809: malloc (vg_replace_malloc.c:149)
==18347== by 0x320E01C283: FcStrCopy (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01F518: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x3747809E94: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780AB53: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780BBB8: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780CC2A: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x3747803ED0: XML_ParseBuffer (in /lib64/libexpat.so.0.5.0)
==18347== by 0x320E01E8B7: FcConfigParseAndLoad (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01EB44: FcConfigParseAndLoad (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01EF97: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x3747809E94: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780AB53: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780BBB8: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780CC2A: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x3747803ED0: XML_ParseBuffer (in /lib64/libexpat.so.0.5.0)
==18347== by 0x320E01E8B7: FcConfigParseAndLoad (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E0143A1: FcInitLoadConfig (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E014405: FcInitLoadConfigAndFonts (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x3A17580D8D: LoadFontConfigFonts (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A17581F19: GetTypeInfo (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A175825B1: GetTypeInfoByFamily (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A17442E60: (within /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A174434D3: GetTypeMetrics (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A175105AA: MontageImageList (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A170A99AC: MagickMontageImage (in /usr/lib64/libMagickWand.so.3.0.0)
==18347== by 0x40201A: main (fftile_p.c:217)
==18347==
==18347==
==18347== 2,016 bytes in 7 blocks are possibly lost in loss record 25 of 34
==18347== at 0x4A04B32: calloc (vg_replace_malloc.c:279)
==18347== by 0x373F40FC82: _dl_allocate_tls (in /lib64/ld-2.5.so)
==18347== by 0x3740406904: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.5.so)
==18347== by 0x3A168042B1: (within /usr/lib64/libgomp.so.1.0.0)
==18347== by 0x3A174FBCA4: SetImageBackgroundColor (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A17510B61: MontageImageList (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A170A99AC: MagickMontageImage (in /usr/lib64/libMagickWand.so.3.0.0)
==18347== by 0x40201A: main (fftile_p.c:217)
==18347== 2,592 (2,304 direct, 288 indirect) bytes in 9 blocks are definitely lost in loss record 27 of 34
==18347== at 0x4A05809: malloc (vg_replace_malloc.c:149)
==18347== by 0x320E019BCB: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01A4D1: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01A5D4: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01F44B: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x3747809E94: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780AB53: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780BBB8: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780CC2A: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x3747803ED0: XML_ParseBuffer (in /lib64/libexpat.so.0.5.0)
==18347== by 0x320E01E8B7: FcConfigParseAndLoad (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01EB44: FcConfigParseAndLoad (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01EF97: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x3747809E94: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780AB53: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780BBB8: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780CC2A: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x3747803ED0: XML_ParseBuffer (in /lib64/libexpat.so.0.5.0)
==18347== by 0x320E01E8B7: FcConfigParseAndLoad (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E0143A1: FcInitLoadConfig (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E014405: FcInitLoadConfigAndFonts (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E0144DC: FcInit (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E00CB51: FcConfigGetCurrent (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01618E: FcFontList (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x3A17580DFC: LoadFontConfigFonts (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A17581F19: GetTypeInfo (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A175825B1: GetTypeInfoByFamily (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A17442E60: (within /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A174434D3: GetTypeMetrics (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A175105AA: MontageImageList (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A170A99AC: MagickMontageImage (in /usr/lib64/libMagickWand.so.3.0.0)
==18347== by 0x40201A: main (fftile_p.c:217)
any suggestion/help?
==18347== 428 bytes in 18 blocks are definitely lost in loss record 20 of 34
==18347== at 0x4A05809: malloc (vg_replace_malloc.c:149)
==18347== by 0x320E01C283: FcStrCopy (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01F518: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x3747809E94: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780AB53: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780BBB8: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780CC2A: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x3747803ED0: XML_ParseBuffer (in /lib64/libexpat.so.0.5.0)
==18347== by 0x320E01E8B7: FcConfigParseAndLoad (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01EB44: FcConfigParseAndLoad (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01EF97: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x3747809E94: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780AB53: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780BBB8: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780CC2A: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x3747803ED0: XML_ParseBuffer (in /lib64/libexpat.so.0.5.0)
==18347== by 0x320E01E8B7: FcConfigParseAndLoad (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E0143A1: FcInitLoadConfig (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E014405: FcInitLoadConfigAndFonts (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x3A17580D8D: LoadFontConfigFonts (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A17581F19: GetTypeInfo (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A175825B1: GetTypeInfoByFamily (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A17442E60: (within /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A174434D3: GetTypeMetrics (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A175105AA: MontageImageList (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A170A99AC: MagickMontageImage (in /usr/lib64/libMagickWand.so.3.0.0)
==18347== by 0x40201A: main (fftile_p.c:217)
==18347==
==18347==
==18347== 2,016 bytes in 7 blocks are possibly lost in loss record 25 of 34
==18347== at 0x4A04B32: calloc (vg_replace_malloc.c:279)
==18347== by 0x373F40FC82: _dl_allocate_tls (in /lib64/ld-2.5.so)
==18347== by 0x3740406904: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.5.so)
==18347== by 0x3A168042B1: (within /usr/lib64/libgomp.so.1.0.0)
==18347== by 0x3A174FBCA4: SetImageBackgroundColor (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A17510B61: MontageImageList (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A170A99AC: MagickMontageImage (in /usr/lib64/libMagickWand.so.3.0.0)
==18347== by 0x40201A: main (fftile_p.c:217)
==18347== 2,592 (2,304 direct, 288 indirect) bytes in 9 blocks are definitely lost in loss record 27 of 34
==18347== at 0x4A05809: malloc (vg_replace_malloc.c:149)
==18347== by 0x320E019BCB: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01A4D1: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01A5D4: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01F44B: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x3747809E94: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780AB53: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780BBB8: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780CC2A: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x3747803ED0: XML_ParseBuffer (in /lib64/libexpat.so.0.5.0)
==18347== by 0x320E01E8B7: FcConfigParseAndLoad (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01EB44: FcConfigParseAndLoad (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01EF97: (within /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x3747809E94: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780AB53: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780BBB8: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x374780CC2A: (within /lib64/libexpat.so.0.5.0)
==18347== by 0x3747803ED0: XML_ParseBuffer (in /lib64/libexpat.so.0.5.0)
==18347== by 0x320E01E8B7: FcConfigParseAndLoad (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E0143A1: FcInitLoadConfig (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E014405: FcInitLoadConfigAndFonts (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E0144DC: FcInit (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E00CB51: FcConfigGetCurrent (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x320E01618E: FcFontList (in /usr/lib64/libfontconfig.so.1.1.0)
==18347== by 0x3A17580DFC: LoadFontConfigFonts (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A17581F19: GetTypeInfo (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A175825B1: GetTypeInfoByFamily (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A17442E60: (within /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A174434D3: GetTypeMetrics (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A175105AA: MontageImageList (in /usr/lib64/libMagickCore.so.3.0.0)
==18347== by 0x3A170A99AC: MagickMontageImage (in /usr/lib64/libMagickWand.so.3.0.0)
==18347== by 0x40201A: main (fftile_p.c:217)
any suggestion/help?
Re: image order in MagickMontageImage
After each MagickReadImage(), move the iterator with MagickSetLastIterator():
- status=MagickReadImage(image,"1.png");
MagickSetLastIterator(image);
status=MagickReadImage(image,"2.png");
MagickSetLastIterator(image);
- d_wand=DestroyDrawingWand(d_wand);
Re: image order in MagickMontageImage
magick wrote:After each MagickReadImage(), move the iterator with MagickSetLastIterator():
Concerning the memory leak. Don't forget to destroy the drawing wand:
- status=MagickReadImage(image,"1.png");
MagickSetLastIterator(image);
status=MagickReadImage(image,"2.png");
MagickSetLastIterator(image);
- d_wand=DestroyDrawingWand(d_wand);
Thanks. the order is right now. great help.
Valgrind complains MagickMontageImage function memory leak. any suggestion?
Re: image order in MagickMontageImage
The complaints appear to be coming from the font-config delegate library, not ImageMagick. There is also a bit of memory left over by the Posix threads. Both of these are outside our control. One posting says "most of your reported leaks are false positives due to gobject's use of glib's slice allocator.". We added a DestroyPixelWand(p_wand) to your code and valgrind reports:
- ==23230== LEAK SUMMARY:
==23230== definitely lost: 0 bytes in 0 blocks
==23230== indirectly lost: 0 bytes in 0 blocks
Re: image order in MagickMontageImage
Hi,
I am also new to imageMagick, and i'm trying to use the same method as mlin@pelmorex.com did, the MagickMontageImage method,
but the magic wand i receive as result is 0x0 (empty). I am using the version 6.6.1-5 of imageMagick libraries compiled for
iPhone.
Here the code i'm trying to execute:
Can someone help me please?
Regards
I am also new to imageMagick, and i'm trying to use the same method as mlin@pelmorex.com did, the MagickMontageImage method,
but the magic wand i receive as result is 0x0 (empty). I am using the version 6.6.1-5 of imageMagick libraries compiled for
iPhone.
Here the code i'm trying to execute:
Code: Select all
MagickWand *image, magick_wand;
DrawingWand *d_wand;
MagickWandGenesis();
image=NewMagickWand();
status=MagickReadImage(image,"t1.jpeg");
status=MagickReadImage(image,"t2.jpeg");
status=MagickReadImage(image,"t3.jpeg");
status=MagickReadImage(image,"t4.jpeg");
PixelWand *p_wand;
p_wand = NewPixelWand();
PixelSetColor(p_wand,"none");
d_wand = NewDrawingWand();
char geo[10];
memset(geo, '\0', sizeof(geo));
magick_wand = MagickMontageImage(image, d_wand, "1x1+0+0","50x50+0+0",ConcatenateMode,"15x15+3+3");
image=DestroyMagickWand(image);
d_wand = DestroyDrawingWand(d_wand);
p_wand = DestroyPixelWand(p_wand);
Regards