You are not logged in.
Indeed, the problem was in ExecConsoleApp function. I use pipes to redirect output of the console applications. What I wasn't aware of is that pipes use fixed buffer size of system default size if not specified explicitly, which seems to be very small like 4K. The target process would freeze when pipe gets full, while ReNamer would wait (infinitely) until the target process terminates before reading the data from the pipe.
So, I no longer wait for the process to terminate to read its output, I read the data as it becomes available. Problem is fixed. Try latest development version
const
MAGIK = '"C:\Tools\ImageMagick-6.7.1-0\identify.exe" -unique -verbose';
FIND = 'Colors: (\d+)';
var
Command, Output: String;
Matches: TStringsArray;
begin
Command := MAGIK + ' "' + FilePath + '"';
ExecConsoleApp(Command, Output);
Matches := SubMatchesRegEx(Output, FIND, False);
if Length(Matches) > 0 then
FileName := Matches[0] + ' ' + FileName;
end.
Online
I did it!!! :-)
My installed version of ImageMagick is different, and I couldn't make the -unique work
(didn't try with -verbose)
So I used -format and "%k" to make it output exactly the number of unique colors and nothing else,
so there is no need to parse the output.
By the way, this script will work for any kind of image file ImageMagick supports, not only jpeg.
Thank you very much for your help, Andrew, Stefan and Denis! You are the best!
Tatjana
PS: sorry for my bad English. Portuguese gal here
const
MAGIK = '"C:\Programas\ImageMagick-6.6.5-Q16\identify.exe" -format "%k"';
var
Command, Output: String;
Matches: String;
begin
Command := MAGIK + ' "' + FilePath + '"';
ExecConsoleApp(Command, Output);
Matches := Output;
if Length(Matches) > 0 then
FileName := Matches + ' ' + FileName;
end.
Last edited by Tatjana (2011-07-24 08:33)
Offline
Thanks a lot for the fix Denis, and thanks to Tatjana too, otherwise this issue might not have come to light. BTW, that "-format" option was a good find. More help on other format options here, in case anyone wants to extract other data.
P.S. For testing purposes I downloaded the portable version of ImageMagick from the official site, as I wasn't interested in installing it, then uninstalling, cleaning up leftover files and registry entries etc.
Offline