Page 1 of 1

image proerties as arguments

Posted: 2010-12-02T16:49:43-07:00
by GreenKoopa
I would like to set every pixel in an entire image to the image's maximum (or minimum, etc.) value. I tried:

convert -size 100x256 gradient:#000-#999 in.png
convert in.png -evaluate Set %[fx:maxima] out.png
convert in.png -format %[fx:maxima] info: --- 0.6
convert out.png -format %[fx:maxima] info: --- 0

No error, just a solid black output.

If some of my image is fully transparent, will those values be ignored or will I need to set them to black with -alpha Background?

Re: image proerties as arguments

Posted: 2010-12-02T19:17:01-07:00
by fmw42
I am not expert on this, but I don't know if -evaluate set honors %[fx...]. You probably need to get the max value and put it into a variable and then use that to change the image

max=`convert image -format "%[fx:100*maxima]" info:`
convert image -fill "gray($max%)" -colorize 100% result

Re: image proerties as arguments

Posted: 2010-12-02T19:24:47-07:00
by GreenKoopa
I have tried using %[max]. I have also tried a -set option: arrangement.

The solution wouldn't have to involve -evaluate, it was just the only idea I had.

Re: image proerties as arguments

Posted: 2010-12-02T19:26:03-07:00
by fmw42
GreenKoopa wrote:I have tried using %[max]. I have also tried a -set option: arrangement.

The solution wouldn't have to involve -evaluate, it was just the only idea I had.

Perhaps you missed my solution right above your note. Seems like we submitted at about the same time.

max=`convert image -format "%[fx:100*maxima]" info:`
convert image -fill "gray($max%)" -colorize 100% result

Re: image proerties as arguments

Posted: 2010-12-02T20:07:18-07:00
by GreenKoopa
Thank you, scripting outside of IM is certainly one solution. -fx maxima is one too (but very slow). My original try didn't give an error so I just wondered if I was close. My try did result in some unexpected behavior, so my curiosity increased.

Re: image proerties as arguments

Posted: 2010-12-02T21:28:00-07:00
by anthony
At this time only very specific options allow you to specify arguments using escape sequences.

These include...
-set
-annotate
-distort
-sparse-color
-format, -label, -caption & -comment (though really they store the string for later expansion)

However most options do NOT. They either take a 'geometry' string, or color value.

Remember both 'geometry' and 'color' strings could include '%' in them, and those percents must NOT be expanded as being percent escapes.

proposal


One proposed solution is that percent escapes must not have a digit before it unless followed by a '[' or '%'. As such these are not percent escaped...

100%x30 rgb(100%,100%,100%,.5)

But these are expanded as percent escapes...

100%% %wx%h max=%[maximum]

That is the first escapes the percent shrinking it to one percent, the others do not have a digit before it

If this proposal can be done, then there is no reason why ALL option arguments could not have percent escapes.

THE EXCEPTION to this is -define -label -caption -comment, which much store the given string, including all percent escapes for later expansion when the saved value is actually used with an actual image.

see older raw notes on this type of problem in
http://www.imagemagick.org/Usage/bugs/future/#settings

Re: image proerties as arguments

Posted: 2010-12-02T22:17:36-07:00
by GreenKoopa
Good proposal! More functionality but no added complexity for the user who doesn't need it.

Probably can't be done for historical compatibly reasons, but I propose that the % symbol never be used. Countless hours have been wasted by us outcast Windows users. :(

Re: image proerties as arguments

Posted: 2010-12-02T23:54:38-07:00
by anthony
It was before my time (way before) but % I belied was picked originally because it was not $ whcih was already heavily used by shells, perl, and PHP. :?

It just happened that % was used by DOS! :(

If you are feeling down trodden, you could always install CgiWin and get a BASH shell on a windows box :lol:

Re: image proerties as arguments

Posted: 2010-12-03T00:30:34-07:00
by GreenKoopa
anthony wrote: If you are feeling down trodden, you could always install CgiWin and get a BASH shell on a windows box :lol:
I should know more of linux. I know a bit of Perl, but then I change Windows machines and it's not available. Or I could learn VBScript or Windows PowerShell. My curiosity exceeds my time and talent. :(