txt:- error

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?".
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

txt:- error

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: txt:- error

Post by fmw42 »

If you are on windows, you must escape % with %% and double quote hex colors.
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: txt:- error

Post by VanGog »

Sorry I am doing this mistake still around
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: txt:- error

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: txt:- error

Post 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.
Last edited by fmw42 on 2012-05-22T21:01:18-07:00, edited 1 time in total.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: txt:- error

Post 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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: txt:- error

Post 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.
Werty
Posts: 66
Joined: 2010-08-06T05:37:36-07:00
Authentication code: 8675308

Re: txt:- error

Post by Werty »

In the initial post he uses "grep" which is for *nix systems, unless he has installed some windows version of it. :p
Windows 7 user
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: txt:- error

Post 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
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: txt:- error

Post 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 :-(
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: txt:- error

Post 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.
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: txt:- error

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: txt:- error

Post 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.
VanGog
Posts: 308
Joined: 2012-02-05T02:46:58-07:00
Authentication code: 8675308

Re: txt:- error

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: txt:- error

Post 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
Post Reply