(Solved) convert -level not working properly

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
fernandokts

(Solved) convert -level not working properly

Post by fernandokts »

When I use convert with the -level parameter, it affects everything in the command, even if I separate the other images with "\( \)"

Example:
convert \( rose: -level 70,75% \) \( rose: \) -compose Screen -composite rose.jpg

When I use the above command, the first and the second "rose:" is affected by -level.

But when I do exactly the same thing with any other parameter, like blur, it works ok (affecting only the first "rose:").

Example:
convert \( rose: -blur 0x5 \) \( rose: \) -compose Screen -composite rose.jpg

The above command works fine. It seems to happen only with "-level"

I'm currently using ImageMagick 6.4.9-3 in linux.
Last edited by fernandokts on 2009-03-10T21:05:40-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert -level not working properly

Post by fmw42 »

see -respect-parenthesis http://www.imagemagick.org/script/comma ... arentheses

convert -respect-parenthesis \( rose: -level 70,75% \) \( rose: \) -compose Screen -composite rose.jpg
fernandokts

Re: convert -level not working properly

Post by fernandokts »

It still doesn't work.
With other filters the parentheses are being respected even without "respect-parentheses".

Thank you for your reply.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert -level not working properly

Post by fmw42 »

fernandokts wrote:It still doesn't work.
With other filters the parentheses are being respected even without "respect-parentheses".

Thank you for your reply.
It is singular, -respect-parenthesis, not plural -respect-parentheses. Did you misspell it?


This seems to work fine for me:

convert -respect-parenthesis \( rose: -level 70,75% \) \( rose: \) +append rose_append.jpg

This also works fine for me:

convert \( rose: -level 70,75% \) \( rose: \) +append rose_append2.jpg


So might it be related to your -compose screen -composite?

see http://www.imagemagick.org/Usage/compose/#screen to see if that is the compose setting you really want.
fernandokts

Re: convert -level not working properly

Post by fernandokts »

Actually I used in singular, just wrote wrong in the forum.
That is really strange...
When I save an image of the "-level" command with "rose:", and then do the compose, it works. It only doesn't work when I try to do all in the same line.

convert rose: -level 70,75% rose_highcontrast.jpg
convert rose_highcontrast.jpg rose: -compose screen -composite rose_final.jpg

The above works. But I need to do it all in the same line, cause I'm making a script to do this with an image sequence. So I think, it would be faster not using a temporarily file.

Actually, It doesn't work with any other -compose mode (Plus, Multiply, etc...)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert -level not working properly

Post by fmw42 »

fernandokts wrote:Actually I used in singular, just wrote wrong in the forum.
That is really strange...
When I save an image of the "-level" command with "rose:", and then do the compose, it works. It only doesn't work when I try to do all in the same line.

convert rose: -level 70,75% rose_highcontrast.jpg
convert rose_highcontrast.jpg rose: -compose screen -composite rose_final.jpg

The above works. But I need to do it all in the same line, cause I'm making a script to do this with an image sequence. So I think, it would be faster not using a temporarily file.

Actually, It doesn't work with any other -compose mode (Plus, Multiply, etc...)

These all seems to work for me and produces the same result as your rose_final.jpg

convert \( rose: -level 70,75% \) rose: -compose screen -composite rose_test1.jpg

convert rose: \( +clone -level 70,75% \) -compose screen -composite rose_test2.jpg

convert rose: \( +clone -level 70,75% \) -compose lighten -composite rose_test3.jpg

convert \( rose: -level 70,75% \) miff:- | convert - rose: -compose screen -composite rose_test4.jpg

convert \( rose: -level 70,75% -write mpr:rose \) -delete 0 mpr:rose rose: -compose screen -composite rose_test5.jpg

IM 6.4.9-8 Q16 Mac OSX Tiger
fernandokts

Re: convert -level not working properly

Post by fernandokts »

fmw42 wrote:
fernandokts wrote:Actually I used in singular, just wrote wrong in the forum.
That is really strange...
When I save an image of the "-level" command with "rose:", and then do the compose, it works. It only doesn't work when I try to do all in the same line.

convert rose: -level 70,75% rose_highcontrast.jpg
convert rose_highcontrast.jpg rose: -compose screen -composite rose_final.jpg

The above works. But I need to do it all in the same line, cause I'm making a script to do this with an image sequence. So I think, it would be faster not using a temporarily file.

Actually, It doesn't work with any other -compose mode (Plus, Multiply, etc...)

These all seems to work for me and produces the same result as your rose_final.jpg

convert \( rose: -level 70,75% \) rose: -compose screen -composite rose_test1.jpg

convert rose: \( +clone -level 70,75% \) -compose screen -composite rose_test2.jpg

convert rose: \( +clone -level 70,75% \) -compose lighten -composite rose_test3.jpg

convert \( rose: -level 70,75% \) miff:- | convert - rose: -compose screen -composite rose_test4.jpg

convert \( rose: -level 70,75% -write mpr:rose \) -delete 0 mpr:rose rose: -compose screen -composite rose_test5.jpg

IM 6.4.9-8 Q16 Mac OSX Tiger
All your examples that use lighten work for me, but the ones that use screen don't.
And when I write to an image, then load it in other command with screen, it works. I will do with the lighten, that is almost the same as screen.

Thank's fmw42, for your attention and patience!
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: convert -level not working properly

Post by anthony »

fernandokts wrote:When I use convert with the -level parameter, it affects everything in the command, even if I separate the other images with "\( \)"

Example:
convert \( rose: -level 70,75% \) \( rose: \) -compose Screen -composite rose.jpg

When I use the above command, the first and the second "rose:" is affected by -level.
when I remove the composition of the two images I see that -level was only applied to the first rose image. the second was NOT effected. Of course -screen will combine things and so a change in one rose image will effect the overall result.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
fernandokts

Re: convert -level not working properly

Post by fernandokts »

anthony wrote: when I remove the composition of the two images I see that -level was only applied to the first rose image. the second was NOT effected. Of course -screen will combine things and so a change in one rose image will effect the overall result.
Anthony,
when you do this without the -composite, it generates two images: rose-0.jpg and rose-1.jpg.
The rose-0.jpg is the result of the first part of the command "\( rose: -level 70,75% \)" and rose-1.jpg is the result of the second part "rose:", without -composite the -compose Screen is ignored right?

So, when you type this:
convert \( rose-0.jpg \) \( rose-1.jpg \) -compose Screen -composite final.jpg

Shouldn't it be the same as:
convert \( rose: -level 70,75% \) \( rose: \) -compose Screen -composite final.jpg
??

I'm just curious why they return different results...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert -level not working properly

Post by fmw42 »

All your examples that use lighten work for me, but the ones that use screen don't.
And when I write to an image, then load it in other command with screen, it works. I will do with the lighten, that is almost the same as screen.
Perhaps it is just you particular version of IM. Have you tried upgrading to the latest?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: convert -level not working properly

Post by anthony »

Have you tried using MIFF or PNG rather than lossy JPG for intermediate results?
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
fernandokts

Re: convert -level not working properly

Post by fernandokts »

fmw42 wrote:Perhaps it is just you particular version of IM. Have you tried upgrading to the latest?
You're right!
I was using 6.4.9-3, and now I'm using 6.4.9-9 from today's SVN, and it works!

anthony wrote:Have you tried using MIFF or PNG rather than lossy JPG for intermediate results?
I was using intermediate, just as an example... But I agree, the intermediate results should always use lossless formats.

Thank you all for your time!
Post Reply