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?
image proerties as arguments
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: image proerties as arguments
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
max=`convert image -format "%[fx:100*maxima]" info:`
convert image -fill "gray($max%)" -colorize 100% result
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
Re: image proerties as arguments
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.
The solution wouldn't have to involve -evaluate, it was just the only idea I had.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: image proerties as arguments
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
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
Re: image proerties as arguments
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.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: image proerties as arguments
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
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
Re: image proerties as arguments
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.
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.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: image proerties as arguments
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
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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
Re: image proerties as arguments
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.anthony wrote: If you are feeling down trodden, you could always install CgiWin and get a BASH shell on a windows box