Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x2="1" is removed in <linearGradient #225

Open
JoKalliauer opened this issue Feb 23, 2019 · 10 comments · May be fixed by #271
Open

x2="1" is removed in <linearGradient #225

JoKalliauer opened this issue Feb 23, 2019 · 10 comments · May be fixed by #271

Comments

@JoKalliauer
Copy link

JoKalliauer commented Feb 23, 2019

Prozessing File:Wing_camber_and_aileron_FAA_GFH.svg breaks the file.

scour Input.svg.txt Output.svg.txt

Input

<?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="0 0 830.62 351.35" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 <linearGradient id="a" gradientUnits="userSpaceOnUse">
  <stop stop-color="#6d6961" offset="0"/>
  <stop stop-color="#f4f4f4" offset=".24"/>
  <stop stop-color="#f4f4f4" offset=".755"/>
  <stop stop-color="#6d6961" offset="1"/>
 </linearGradient>
 <linearGradient id="b" x2="1" gradientTransform="matrix(0 55.906 -55.906 0 679.4 171)" xlink:href="#a"/>
 <linearGradient id="c" x2="1" gradientTransform="matrix(0 135.52 -135.52 0 338.1 120.7)" xlink:href="#a"/>
 <linearGradient id="d" x2="1" gradientTransform="matrix(0 135.52 -135.52 0 338.9 120.7)" xlink:href="#a"/>
 <path d="m73.899 210.314c0 10.615 6.456 45.833 69.868 41.78 205.423-13.141 423.986-17.597 454.689-17.755-10.291-1.482-14.799-14.82-14.418-28.155.42-14.771 6.847-29.545 18.076-28.208-21.248-2.939-239.73-32.699-353.275-32.699a425.596 425.596 0 0 0 -12.587-.187c-126.355-.007-162.352 57.856-162.352 65.225m529.516-32.163c-.233-.03-.579-.08-1.037-.141-.085-.02-.176-.02-.265-.04.586.08 1.02.141 1.302.176.49.07.501.07 0 0m-4.96 56.187c.84.12 1.718.162 2.632.116 1.697-.08 1.263-.123-1.108-.123-.441 0-.949.004-1.524.007" fill="url(#d)"/>
 <path d="m602.38 178.02c22.43 3.168-228.8-32.73-353.54-32.734-136.6-3.997-174.9 57.43-174.94 65.042 0 10.61 6.452 45.83 69.868 41.776 229.9-14.7 476.2-18.54 457.32-17.639-24.7 1.175-21.14-59.61 1.291-56.445z" fill="none" stroke="#231f20" stroke-linecap="round" stroke-linejoin="round" stroke-width=".88"/>
 <path d="m73.899 210.31 510.21.621c-.984-16.26 5.648-34.67 18.239-32.928-19.55-2.702-239.4-32.73-353.51-32.731a425.6 425.6 0 0 0 -12.587-.187c-126.4-.007-162.4 57.86-162.35 65.225" fill="url(#c)"/>
 <path d="m584.1 210.93c-.984-16.26 5.648-34.67 18.239-32.928-19.55-2.702-239.4-32.73-353.51-32.731-136.6-3.997-174.9 57.43-174.94 65.042" fill="none" stroke="#231f20" stroke-linecap="round" stroke-linejoin="round" stroke-width=".88"/>
 <path d="m590.58 205.98c-1.196 13.55 4.868 27.1 20.68 26.317 12.84-.632 157-20.63 157.01-20.631s-61.74-15.79-154.31-31.969c-.529-.05-1.055-.07-1.566-.07-12.62 0-20.65 13.17-21.809 26.349" fill="url(#b)"/>
 <path d="m613.95 179.68c-26.86-2.272-34.51 54.17-2.699 52.603 12.84-.635 157-20.63 157.01-20.63s-61.74-15.79-154.31-31.972z" fill="none" stroke="#231f20" stroke-linecap="round" stroke-linejoin="round" stroke-width=".88"/>
</svg>

input

Output

<?xml version="1.0" encoding="UTF-8"?>
<svg viewBox="0 0 830.62 351.35" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 <linearGradient id="a" gradientUnits="userSpaceOnUse">
  <stop stop-color="#6d6961" offset="0"/>
  <stop stop-color="#f4f4f4" offset=".24"/>
  <stop stop-color="#f4f4f4" offset=".755"/>
  <stop stop-color="#6d6961" offset="1"/>
 </linearGradient>
 <linearGradient id="b" gradientTransform="matrix(0 55.906 -55.906 0 679.4 171)" xlink:href="#a"/>
 <linearGradient id="c" gradientTransform="matrix(0 135.52 -135.52 0 338.1 120.7)" xlink:href="#a"/>
 <linearGradient id="d" gradientTransform="matrix(0 135.52 -135.52 0 338.9 120.7)" xlink:href="#a"/>
 <path d="m73.899 210.314c0 10.615 6.456 45.833 69.868 41.78 205.423-13.141 423.986-17.597 454.689-17.755-10.291-1.482-14.799-14.82-14.418-28.155.42-14.771 6.847-29.545 18.076-28.208-21.248-2.939-239.73-32.699-353.275-32.699a425.596 425.596 0 0 0 -12.587-.187c-126.355-.007-162.352 57.856-162.352 65.225m529.516-32.163c-.233-.03-.579-.08-1.037-.141-.085-.02-.176-.02-.265-.04.586.08 1.02.141 1.302.176.49.07.501.07 0 0m-4.96 56.187c.84.12 1.718.162 2.632.116 1.697-.08 1.263-.123-1.108-.123-.441 0-.949.004-1.524.007" fill="url(#d)"/>
 <path d="m602.38 178.02c22.43 3.168-228.8-32.73-353.54-32.734-136.6-3.997-174.9 57.43-174.94 65.042 0 10.61 6.452 45.83 69.868 41.776 229.9-14.7 476.2-18.54 457.32-17.639-24.7 1.175-21.14-59.61 1.291-56.445z" fill="none" stroke="#231f20" stroke-linecap="round" stroke-linejoin="round" stroke-width=".88"/>
 <path d="m73.899 210.31 510.21.621c-.984-16.26 5.648-34.67 18.239-32.928-19.55-2.702-239.4-32.73-353.51-32.731a425.6 425.6 0 0 0 -12.587-.187c-126.4-.007-162.4 57.86-162.35 65.225" fill="url(#c)"/>
 <path d="m584.1 210.93c-.984-16.26 5.648-34.67 18.239-32.928-19.55-2.702-239.4-32.73-353.51-32.731-136.6-3.997-174.9 57.43-174.94 65.042" fill="none" stroke="#231f20" stroke-linecap="round" stroke-linejoin="round" stroke-width=".88"/>
 <path d="m590.58 205.98c-1.196 13.55 4.868 27.1 20.68 26.317 12.84-.632 157-20.63 157.01-20.631s-61.74-15.79-154.31-31.969c-.529-.05-1.055-.07-1.566-.07-12.62 0-20.65 13.17-21.809 26.349" fill="url(#b)"/>
 <path d="m613.95 179.68c-26.86-2.272-34.51 54.17-2.699 52.603 12.84-.635 157-20.63 157.01-20.63s-61.74-15.79-154.31-31.972z" fill="none" stroke="#231f20" stroke-linecap="round" stroke-linejoin="round" stroke-width=".88"/>
</svg>

Difference

screenshot 2019-02-23 08 48 13

Rendering in Firefox
screenshot 2019-02-23 08 51 01

Similar rendering in Crome

Copyright

Lizense: Public Domain

Source: https://commons.wikimedia.org/wiki/File:Wing_camber_and_aileron_FAA_GFH.svg

@nthykier
Copy link
Contributor

As I understanding it, the underlying issue here is that scour fails to cope with the fact that gradientUnits is effectively set to userSpaceOnUse via the xlink:href. If it had been set directly on the <linearGradient> tag then I think the code would not have pruned it.

@nthykier

This comment has been minimized.

nthykier added a commit to nthykier/scour that referenced this issue Feb 27, 2021
When considering to prune attributes set to a default values, we
checked the `gradientUnits` attribute first to determine if that was
valid. Unfortunately, we omitted to check whether the `gradientUnits`
attribute was inherited via `xlink:ref`.  This commit corrects that
bug.

Closes: scour-project#225
Signed-off-by: Niels Thykier <[email protected]>
@nthykier nthykier linked a pull request Feb 27, 2021 that will close this issue
@nthykier
Copy link
Contributor

Hi @JoKalliauer

Could you check whether #271 fixes this problem for you? :)

@JoKalliauer
Copy link
Author

JoKalliauer commented Feb 28, 2021

@nthykier

Could you check whether #271 fixes this problem for you? :)

To answer your Question: Not shure if I can. ;)


Some additional information

What I did was

python3 -m pip install --upgrade pip --user
pip3 install --upgrade https://github.com/codedread/scour/archive/master.zip --user
pip install https://github.com/codedread/scour/archive/master.zip
scour --version
wget https://github.com/scour-project/scour/files/2896595/Input.svg.txt
scour Input.svg.txt Output.svg
vimdiff Input.svg.txt Output.svg
scour -i Input.svg.txt -o AllDeactivated.svg --indent=space --nindent=1 --disable-simplify-colors --disable-style-to-xml  --disable-group-collapsing --keep-editor-data --keep-unreferenced-defs --protect-ids-noninkscape  --disable-embed-rasters --set-precision=6

TerminalOutput of the comands above

$ python3 -m pip install --upgrade pip --user
Requirement already satisfied: pip in /home/jkalliau/.local/lib/python3.8/site-packages (21.0.1)
$ pip3 install --upgrade https://github.com/codedread/scour/archive/master.zip --user
Collecting https://github.com/codedread/scour/archive/master.zip
  Using cached https://github.com/codedread/scour/archive/master.zip
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3.8/site-packages (from scour==0.38.2) (1.14.0)
$ pip install https://github.com/codedread/scour/archive/master.zip
Defaulting to user installation because normal site-packages is not writeable
Collecting https://github.com/codedread/scour/archive/master.zip
  Using cached https://github.com/codedread/scour/archive/master.zip
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3.8/site-packages (from scour==0.38.2) (1.14.0)
$ scour --version
0.38.2
$ wget https://github.com/scour-project/scour/files/2896595/Input.svg.txt
--2021-02-28 10:17:51--  https://github.com/scour-project/scour/files/2896595/Input.svg.txt
Resolving github.com (github.com)... 140.82.121.3
Connecting to github.com (github.com)|140.82.121.3|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://github-repository-files.githubusercontent.com/13775110/2896595?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210228%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210228T091751Z&X-Amz-Expires=300&X-Amz-Signature=610f3473a61c0a634994c220523ed22022c060e2fa633f788d22e371bb62ebd0&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=13775110&response-content-disposition=attachment%3Bfilename%3DInput.svg.txt&response-content-type=text%2Fplain [following]
--2021-02-28 10:17:51--  https://github-repository-files.githubusercontent.com/13775110/2896595?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20210228%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20210228T091751Z&X-Amz-Expires=300&X-Amz-Signature=610f3473a61c0a634994c220523ed22022c060e2fa633f788d22e371bb62ebd0&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=13775110&response-content-disposition=attachment%3Bfilename%3DInput.svg.txt&response-content-type=text%2Fplain
Resolving github-repository-files.githubusercontent.com (github-repository-files.githubusercontent.com)... 185.199.110.154, 185.199.111.154, 185.199.109.154, ...
Connecting to github-repository-files.githubusercontent.com (github-repository-files.githubusercontent.com)|185.199.110.154|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2434 (2,4K) [text/plain]
Saving to: ‘Input.svg.txt’

Input.svg.txt                                               100%[=========================================================================================================================================>]   2,38K  --.-KB/s    in 0s      

2021-02-28 10:17:51 (20,2 MB/s) - ‘Input.svg.txt’ saved [2434/2434]
$ scour Input.svg.txt Output.svg 
Scour processed file "Input.svg.txt" in 4 ms: 2413/2434 bytes new/orig -> 99.1%
$ vimdiff Input.svg.txt Output.svg

Screenshot from 2021-02-28 10-23-03

$ scour -i Input.svg.txt -o AllDeactivated.svg --indent=space --nindent=1 --disable-simplify-colors --disable-style-to-xml  --disable-group-collapsing --keep-editor-data --keep-unreferenced-defs --protect-ids-noninkscape  --disable-embed-rasters --set-precision=6
Scour processed file "Input.svg.txt" in 4 ms: 2413/2434 bytes new/orig -> 99.1%

Conclusion with my scour 0.38.2

@nthykier
Copy link
Contributor

nthykier commented Feb 28, 2021

It seems like you were testing the master branch, but the relevant code has not been merged into master yet. Therefore, I do not think you have tested the change.

You might be able to test it by trying to use pip3 install --upgrade https://github.com/nthykier/scour/archive/gh-225-gradient-fix.zip --user (remember to revert back to the master branch when you are done).

@JoKalliauer
Copy link
Author

@nthykier
I still get the same output

$ pip3 install --upgrade https://github.com/nthykier/scour/archive/gh-225-gradient-fix.zip --user
Collecting https://github.com/nthykier/scour/archive/gh-225-gradient-fix.zip
  Using cached https://github.com/nthykier/scour/archive/gh-225-gradient-fix.zip
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3.8/site-packages (from scour==0.38.2) (1.14.0)
$ scour Input.svg.txt Output.svg 
Scour processed file "Input.svg.txt" in 4 ms: 2413/2434 bytes new/orig -> 99.1%

I also tried it with --force

pip3 install https://github.com/nthykier/scour/archive/gh-225-gradient-fix.zip --force
Defaulting to user installation because normal site-packages is not writeable
Collecting https://github.com/nthykier/scour/archive/gh-225-gradient-fix.zip
  Using cached https://github.com/nthykier/scour/archive/gh-225-gradient-fix.zip
Collecting six>=1.9.0
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Building wheels for collected packages: scour
  Building wheel for scour (setup.py) ... done
  Created wheel for scour: filename=scour-0.38.2-py3-none-any.whl size=59054 sha256=a03e2531fc8b2871c7a37ea8c5eb4747f018c844da125a2894a10103a8317cf5
  Stored in directory: /home/jkalliau/.cache/pip/wheels/76/db/36/371ba3855fc9f0748e1ad16b5e96a05ff34c1e5cc1a2e19470
Successfully built scour
Installing collected packages: six, scour
  Attempting uninstall: six
    Found existing installation: six 1.15.0
    Uninstalling six-1.15.0:
      Successfully uninstalled six-1.15.0
  Attempting uninstall: scour
    Found existing installation: scour 0.38.2
    Uninstalling scour-0.38.2:
      Successfully uninstalled scour-0.38.2
Successfully installed scour-0.38.2 six-1.15.0

But scour Input.svg.txt Output.svg also resulted in the same Output.svg.

nthykier added a commit to nthykier/scour that referenced this issue Feb 28, 2021
When considering to prune attributes set to a default values, we
checked the `gradientUnits` attribute first to determine if that was
valid. Unfortunately, we omitted to check whether the `gradientUnits`
attribute was inherited via `xlink:ref`.  This commit corrects that
bug.

Closes: scour-project#225
Signed-off-by: Niels Thykier <[email protected]>
@nthykier
Copy link
Contributor

Thanks for confirming. I was fooled by the test behaving differently than scour itself.

I have tested directly with scour on your input and now get the right result.

@nthykier
Copy link
Contributor

@JoKalliauer How come you closed this issue? The code fixing it has not been merged yet.

@JoKalliauer
Copy link
Author

@nthykier Sorry https://github.com/nthykier/scour/archive/gh-225-gradient-fix.zip fixed the issue, but not the master-branch.
After merging it can be closed.

@JoKalliauer JoKalliauer reopened this Feb 28, 2021
@nthykier
Copy link
Contributor

Ack, thanks for verifying. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants