Multigradient Script Error

A plethora of command-line scripts that perform geometric transforms, blurs, sharpens, edging, noise removal, and color manipulations.
Post Reply
audas
Posts: 10
Joined: 2016-01-27T02:27:24-07:00
Authentication code: 1151

Multigradient Script Error

Post by audas »

multigradient: line 655: syntax error: unexpected end of file
I have everything running correctly - Cygwin etc and have tested dos2ubunto and checked end of lines to ensure they are terminating correctly.

It looks like there may be an error in this file. I am going to run some more shell and bash tests along with PHP exec calls - but it is failing when all other scripts run fine.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multigradient Script Error

Post by fmw42 »

What was your exact command line and version of Imagemagick?

I can reproduce the error message on one of my examples. I will look into it and report back when fixed.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multigradient Script Error

Post by fmw42 »

I think I have it fixed, now. So download the script again and try it. Let me know if it works or not.
audas
Posts: 10
Joined: 2016-01-27T02:27:24-07:00
Authentication code: 1151

Re: Multigradient Script Error

Post by audas »

Thanks for looking into it.

I found that the COMMENT1 was throwing an error when I looked into the return output from a shell_exec rather than command line. I will now try your corrections.

Also : -

I am noticing that there is no percentage value able to be set for the first pair except for 0 100. For example if I wanted to have simply red and white with red 90% of the way over.

All your examples also seem to follow this rule with red yellow followed by colours with percentage values so I am presuming that this is by design. Am I correct ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multigradient Script Error

Post by fmw42 »

Yes, I removed COMMENT1 and COMMENT2 and that fixed it, I believe.

No, the document page says

-s stops ... STOPS are a space separate list of pairs of colors and percent locations along the gradient enclosed in double quotes. The first and last percent location may be left off and are then assumed to be 0 and 100 (percent). The default="white black" or "white 0 black 100".

If it does not work with first or last colors with percents, let me know.
audas
Posts: 10
Joined: 2016-01-27T02:27:24-07:00
Authentication code: 1151

Re: Multigradient Script Error

Post by audas »

From my experiments percents do not work with first two colors with any combination I can find. To clarify they will always be 0 100. Two colors and any more works - with the third ....n colors but the first two can not be set.

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

Re: Multigradient Script Error

Post by fmw42 »

I will look into this and get back. If that is the case, then I will likely have to add a new argument for the background color. But perhaps I misunderstand. Why would you want it to start other than at the edges of the image? If so, do you want constant color on each side? If so, then just duplicate your first and last colors a second time, but with some percents.

Please clarify further how you think it should operate or show me an example of what you expect for some output.
audas
Posts: 10
Joined: 2016-01-27T02:27:24-07:00
Authentication code: 1151

Re: Multigradient Script Error

Post by audas »

Hi FMW4 -
I have done some further testing. You can indeed accomplish the desired outputs through some clever use of options. However it is incongruous. If I may explain ?

Say for example you want a gradient with RED to WHITE but not a smooth transition, rather red covering most of the image and white only a tiny fraction at the end - red starting at zero and continuing to 90 % of the width then white. Or the opposite - a tiny fraction of red, then white for the remainder.

The obvious format for everything is that the first colour ALWAYS starts at zero and the last colour always fills to the end 100

So RED 10 WHITE would be red for 10% then white - conversely RED 90 WHITE for almost all RED.

This continues through the entire methodology - RED 10 WHITE 20 GREEN 40 etc with each number representing where it starts.

To achieve a RED at 10% then White I have to write - "RED RED 10 WHITE" to achieve a red at 90% then white I have to write "RED WHITE WHITE 90" when I could just write "RED 10 WHITE " or "RED 90 WHITE".

I am wording this badly - but it appears that the methodology approached does not ever need a start and finish - 0 and 100 are implied - if no number is provided the half way point is used - or if one is - the percentage is applied.

Thanks anyway.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multigradient Script Error

Post by fmw42 »

I am not sure I follow what you are saying. Are you saying it works either way or that it only works with the extra first and last values.

If the latter, then how would one know what color to start and end with? Should I assume that it is always the first and last color specified. That is

red 10 ... blue 90

would really mean

red 0 red 10 ... blue 90 blue 100

If so, then I should be able to change it to do that.

I believe I followed the CSS stops concept such that the percents are stops, not widths. If you find this is not the case, then please explain what should be done.
audas
Posts: 10
Joined: 2016-01-27T02:27:24-07:00
Authentication code: 1151

Re: Multigradient Script Error

Post by audas »

Im really sorry to have caused you to spend time without being clear.

"RED WHITE" or "RED 0 WHITE 100" - will produce a smooth gradient from red to white

Any other numbers will produce an error or nothing.

so consider producing this image (made with your script)Image

To produce this we must set the command at "RED RED 90 WHITE"

However to produce this Image we must write

"RED WHITE 27 WHITE"


In my view it would be simpler to assume that the first colour will always start at zero because this is fundamentally true - and then the subsequent number is where it finishes (or the next one starts). THe last colour always finishes at 100.

So the numbers merely represent a percentage of distance across a line. A good example is the gradient maker in photoshop.

So for me to produce the first image I would simply write

"RED 90 WHITE"

the second image

"RED 27 WHITE"

For my own purposes I have created a work around function which checks to see if the first colour is greater than 0, else if the second colour is less than 100, else assume no numerical colour stops.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Multigradient Script Error

Post by fmw42 »

I will look into this. I think it should not be too hard to add the extra colors internally for the first and last colors.
Post Reply