Page 1 of 2

txt:- error

Posted: 2012-05-22T01:30:45-07:00
by VanGog
I'm confused with this error. I copied the command from my notes so it worked before,:

Code: Select all

convert "G1.bmp" -fuzz 25% -fill black +opaque #660000 -fill  white -opaque #660000 txt:- | grep white
convert "G1.bmp" -fuzz 30% -fill black +opaque #660000 -fill  blue -opaque #660000 test.gif txt:- | grep blue
but now I got this error:

Code: Select all

convert.exe: option requires an argument `-fuzz' @ error/convert.c/ConvertImageC
ommand/1550.
convert.exe: option requires an argument `-fuzz' @ error/convert.c/ConvertImageC
ommand/1550.
I wanted just to crop image, find a color and create mask. Then to print white pixels.

Code: Select all

convert "G1.bmp" -crop 300x100+340+400 -fuzz 10% -fill black +opaque #660000 -fill  white -opaque #660000 p.png
Yet my question - is it possible to print the txt information so, that the first printed pixel information would be the first found pixel when from top left? I would not need use loop and condition to compare which coordinates are the less.

Re: txt:- error

Posted: 2012-05-22T10:27:32-07:00
by fmw42
If you are on windows, you must escape % with %% and double quote hex colors.

Re: txt:- error

Posted: 2012-05-22T10:48:37-07:00
by VanGog
Sorry I am doing this mistake still around

Re: txt:- error

Posted: 2012-05-22T19:49:53-07:00
by anthony
And if you are on UNIX you need to quote the '#' which the command line shell would consider to be the start of a comment!

I get.. the error
convert: missing an image filename `+opaque' @ error/convert.c/ConvertImageCommand/3023.

Re: txt:- error

Posted: 2012-05-22T20:58:27-07:00
by fmw42
anthony wrote:And if you are on UNIX you need to quote the '#' which the command line shell would consider to be the start of a comment!

I get.. the error
convert: missing an image filename `+opaque' @ error/convert.c/ConvertImageCommand/3023.

I believe he is on windows, from previous discussions. So the % needs to change to %%. But I am not sure if under windows, hex values need to be quoted and if so double or single.

Re: txt:- error

Posted: 2012-05-22T21:00:04-07:00
by anthony
fmw42 wrote:I believe he is on unix, from previous discussions. So the % needs to change to %%. But I am not sure if under windows, hex values need to be quoted and if so double or single.
'%' is not a special character under UNIX! That is for DOS and its FOR loop.

Re: txt:- error

Posted: 2012-05-22T21:01:34-07:00
by fmw42
anthony wrote:
fmw42 wrote:I believe he is on unix, from previous discussions. So the % needs to change to %%. But I am not sure if under windows, hex values need to be quoted and if so double or single.
'%' is not a special character under UNIX! That is for DOS and its FOR loop.
Sorry typo, he is on windows.

Re: txt:- error

Posted: 2012-05-22T21:55:46-07:00
by Werty
In the initial post he uses "grep" which is for *nix systems, unless he has installed some windows version of it. :p

Re: txt:- error

Posted: 2012-05-22T22:06:50-07:00
by fmw42
Werty wrote:In the initial post he uses "grep" which is for *nix systems, unless he has installed some windows version of it. :p
From previous posts it would appear that he is on windows. See viewtopic.php?f=1&t=20623&start=15#p85209

Re: txt:- error

Posted: 2012-05-23T01:24:17-07:00
by VanGog
I am on Windows, using gnuwin32 and yesterday I installed CGWin for future using of fred's scripts.

In CMD I use this command to get first pixel

Code: Select all

FOR /F "tokens=1 delims=" %%R IN ('convert "file2.bmp" -crop 300x100+340+400 -fuzz 5%% -fill black +opaque #660000 -fill white -opaque #660000 txt:- ^| grep white') DO  (
echo %%R
break
pause
)
But it seems to me that it is very slow. The convert command goes through whole image even I need it to be stopped on first white pixel.

Originally I have picture from screen, which I have to cut to get 300x100px image called file2.bmp. Then convert sends through txt:- some coordinates of white pixels to output and I have to grep it and use For loop and break.

Why cannot the txt: command use some argument like txt:white to filter the white pixels only or some other clever way to get only first pixel?

BTW:
I have rewrite the file with my notes where I copied the commands used in command line and corrected them to have %%. So I hope I will not do this error anymore. Shame on me :-(

Re: txt:- error

Posted: 2012-05-23T10:07:32-07:00
by fmw42
Why cannot the txt: command use some argument like txt:white to filter the white pixels only or some other clever way to get only first pixel?
Just not the way it works. IM is an image processor not a text processor.

Re: txt:- error

Posted: 2012-05-23T11:32:22-07:00
by VanGog
So it cannot work faster? Ain't it the same like you would say "IM can't work faster because it is image processor?" I'm just saying that ain't logical to pass too much information then it is necessary. I believe there is alway way to improve programs. Even I don't know language in which IM works, I have close to programming.

Re: txt:- error

Posted: 2012-05-23T12:17:06-07:00
by fmw42
VanGog wrote:So it cannot work faster? Ain't it the same like you would say "IM can't work faster because it is image processor?" I'm just saying that ain't logical to pass too much information then it is necessary. I believe there is alway way to improve programs. Even I don't know language in which IM works, I have close to programming.
I was talking about making txt: format do filtering. IM is an image processor and not a text processor.

IM reads all input images into memory before processing when using convert. Mogrify will process each image separately, but has more limited functionality.

IM was designed for quality and flexibility and not necessarily designed to have the most optimized speed, though it does allow multithreading.

IM is an open source system, so you are free to submit any software changes you would like.

Any speed issues with speed should be taken up with the IM developers and be specific about what function is slow and give an example with timing.

There may be other ways to use IM that make what you want to do faster. I don't know much about this, but you might be able to stream the images so that they read one line at a time and process that. Also you might get faster results using one of the APIs and adding your own special processing. Others may be able to suggest other ways to help you speed up your command.

Re: txt:- error

Posted: 2012-05-23T13:54:29-07:00
by VanGog
Unfortunately I don't work with C or C++ and I am not image expert. But just a single thought: image of that size, noted above, takes just few miliseconds to load when I use for example FastStone viewer or Window image viewer. But it takes about 1000 miliseconds when I execute the convert to get the txt information.

http://i48.tinypic.com/14ajwjk.png

I also don't know how could I measure time of loading the image, I don't have any tool for it so it is only my guess.

Re: txt:- error

Posted: 2012-05-23T14:26:53-07:00
by fmw42
The time delay is writing all the pixels from binary to ascii text format with all the required information about coordinates and color. That is slow. Note time is a unix function. It will be even slower adding grep. But the main slowdown is converting to txt format.

time convert logo: logo:png
real 0m0.055s
user 0m0.026s
sys 0m0.015s

time convert logo: logo.txt
real 0m2.654s
user 0m2.477s
sys 0m0.034s