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

Black square instead of image because of additional path #2

Open
Ballistx opened this issue Aug 20, 2023 · 3 comments
Open

Black square instead of image because of additional path #2

Ballistx opened this issue Aug 20, 2023 · 3 comments
Assignees

Comments

@Ballistx
Copy link

Ballistx commented Aug 20, 2023

Thanks for this great tool, it helped me a lot! However, it seems like I found an error, but I'm not very into svgs.

When uploading some android xml svgs they were converted to svgs that were just a black square, except for one image that worked. Removing the last path for all svgs that were a black square helped fix the error.


This one worked:

<vector
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:width="24dp"
  android:height="24dp"
  android:viewportWidth="24"
  android:viewportHeight="24"
  android:tint="?attr/colorControlNormal"
>
  <path
    android:fillColor="@android:color/white"
    android:pathData="M17,16l-4,-4V8.82C14.16,8.4 15,7.3 15,6c0,-1.66 -1.34,-3 -3,-3S9,4.34 9,6c0,1.3 0.84,2.4 2,2.82V12l-4,4H3v5h5v-3.05l4,-4.2 4,4.2V21h5v-5h-4z"
  />
</vector>

It converted into:

<svg
  id="vector"
  xmlns="http://www.w3.org/2000/svg"
  width="24"
  height="24"
  viewBox="0 0 24 24"
>
  <path
    fill="@android:color/white"
    d="M17,16l-4,-4V8.82C14.16,8.4 15,7.3 15,6c0,-1.66 -1.34,-3 -3,-3S9,4.34 9,6c0,1.3 0.84,2.4 2,2.82V12l-4,4H3v5h5v-3.05l4,-4.2 4,4.2V21h5v-5h-4z"
    id="path_0"
  />
</svg>

svgviewer-output (6)


This one did not work:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="24dp"
    android:height="24dp"
    android:viewportWidth="24"
    android:viewportHeight="24">
  <path
      android:pathData="M12,2a7,7 0,0 0,-7 7c0,2.38 1.19,4.47 3,5.74V17a1,1 0,0 0,1 1h6a1,1 0,0 0,1 -1v-2.26c1.81,-1.27 3,-3.36 3,-5.74a7,7 0,0 0,-7 -7M9,21a1,1 0,0 0,1 1h4a1,1 0,0 0,1 -1v-1H9v1z"
      android:fillColor="#626262"/>
  <path
      android:pathData="M0,0h24v24h-24z"
      android:fillColor="#00000000"/>
</vector>

It converted into:

<svg
  id="vector"
  xmlns="http://www.w3.org/2000/svg"
  width="24"
  height="24"
  viewBox="0 0 24 24"
>
  <path
    fill="#626262"
    d="M12,2a7,7 0,0 0,-7 7c0,2.38 1.19,4.47 3,5.74V17a1,1 0,0 0,1 1h6a1,1 0,0 0,1 -1v-2.26c1.81,-1.27 3,-3.36 3,-5.74a7,7 0,0 0,-7 -7M9,21a1,1 0,0 0,1 1h4a1,1 0,0 0,1 -1v-1H9v1z"
    id="path_0"
  />
  <path fill="#00000000" d="M0,0h24v24h-24z" id="path_1" />
</svg>

svgviewer-output (3)

Removing the last path fixed it:

<svg
  id="vector"
  xmlns="http://www.w3.org/2000/svg"
  width="24"
  height="24"
  viewBox="0 0 24 24"
>
  <path
    fill="#626262"
    d="M12,2a7,7 0,0 0,-7 7c0,2.38 1.19,4.47 3,5.74V17a1,1 0,0 0,1 1h6a1,1 0,0 0,1 -1v-2.26c1.81,-1.27 3,-3.36 3,-5.74a7,7 0,0 0,-7 -7M9,21a1,1 0,0 0,1 1h4a1,1 0,0 0,1 -1v-1H9v1z"
    id="path_0"
  />
</svg>

svgviewer-output (5)

@seanghay
Copy link
Owner

@Ballistx I don't see the issue in the output svg visually. Can you explain me a bit more?

@seanghay seanghay self-assigned this Aug 21, 2023
@Ballistx
Copy link
Author

@Ballistx I don't see the issue in the output svg visually. Can you explain me a bit more?

Sorry for the late answer. You are right, when opening with a browser they seem to work but not in the android studio view and my flutter app -> There I had to remove the last path which seems to be redudant.

@seanghay
Copy link
Owner

seanghay commented Aug 25, 2023

@Ballistx I think the issue caused by the input VectorDrawable that has two paths. Maybe the issue is a bug which the output SVG uses 8-digit hex incorrectly.

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

No branches or pull requests

2 participants