montage with spaces in filenames

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
seiko
Posts: 7
Joined: 2012-08-01T01:12:37-07:00
Authentication code: 15

montage with spaces in filenames

Post by seiko »

Hello.
I am using this command
p.StartInfo.Arguments = @"montage -tile 9x1 -geometry +0+0 ";
for(i = 0; i < 9; i++)
p.StartInfo.Arguments += " " + pathImages;
p.StartInfo.Arguments += " " + subdir + @"\final.jpeg ";

Here i am adding 9 jpg files from pathImages but it doesnt work if the images have spaces in names. How can i solve this?
Ex:
p.StartInfo.Arguments = @"montage -tile 9x1 -geometry +0+0 p11.jpg p22.jpg final.jpg "; OK
p.StartInfo.Arguments = @"montage -tile 9x1 -geometry +0+0 p1 1.jpg p22.jpg final.jpg "; WRONG because: p1 1.jpg image.

Thanks!
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: montage with spaces in filenames

Post by Bonzo »

I do not know how you will get over the problem as you are using a programing laungage I do not know. But in php and windows I would put " " around the filename.
seiko
Posts: 7
Joined: 2012-08-01T01:12:37-07:00
Authentication code: 15

Re: montage with spaces in filenames

Post by seiko »

After a loooong search this is final version and it is working fine. I put the code here, maybe somebody will need too.

Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.FileName = readDataFromConfigFile("MagicExePath") + @"\MagickCMD.exe"; //read MagicCMD.exe path
p.StartInfo.Arguments = @"montage -tile 9x1 -geometry +0+0 ";
for(i = 0; i < 9; i++)
p.StartInfo.Arguments += " " + (char)34 + pathImages + (char)34; //pathImages contains the address of the images
p.StartInfo.Arguments += " " + (char)34 + subdir + @"\final.jpeg" + (char)34; //the name for the final image
p.StartInfo.CreateNoWindow = true;
p.Start();
p.WaitForExit();
Post Reply