开发者

imagemagick with foreign characters

开发者 https://www.devze.com 2022-12-19 06:38 出处:网络
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

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();


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.


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.


Answering this question may not be helpful for now but it might be useful for someone. Converting file path to UTF-8 encoding worked for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号