views:

39

answers:

2

ImageMagick doesnt seem to work with foreign characters. I use the following code

It works fine until a letter in the path or the file has a foreign character. How do i convert images to thumbs on my asp.net site? Is there a plug in or another app or version i may use?

            Process app = new Process();
            app.StartInfo.FileName = @"bin\convert.exe";
            app.StartInfo.Arguments = string.Format(@"""{0}"" -resize ""{2}"" ""{1}""", file, newfile, param);
            app.Start();
            app.WaitForExit();
+1  A: 

I would change the name of the file. You probably want to be doing some conversion of the file name anyway to help keep yourself safe from attacks embedded in a file's name. It's usually a bad idea to launch a subprocess with any string that a user can control. If you're catching uploaded files, move them to some new name before running convert.exe - like a name generated from a uuid, for instance.

Matt
not helpful. I still need to convert chinese or korean filenames.
acidzombie24
hmm. I don't see how "I would change the name of the file ... move them to some new name before running convert.exe" is different than "A workaround is to change the filename to something ascii safe". I was just pointing out that, quite apart from answering your question, it can be a good practice to increase security. ::shrug:: Glad to see you got a working solution in the end.
Matt
I thought you were saying dont allow users to choice the name PERIOD ( for security reasons). and to use ascii safe names. It didnt occur to me until i sat down and tried to think of a workaround because foreign names seems impossible. I didnt know/think you were suggesting what my answer is suggesting. -edit- i'll +1 you anyways ;)
acidzombie24
A: 

A workaround is to change the filename to something ascii safe then rename/move it to the name/path you want with full unicode characters.

acidzombie24
If someone gives me a better answer then i may switch the accepting answer but this solution is fair enough.
acidzombie24