image icon indicating copy to clipboard operation
image copied to clipboard

SVG Images taking black background

Open vinoddotcom opened this issue 2 years ago • 10 comments

When using SVG images within the <nuxt-img> tag, an automatic black background is applied, even though SVG images typically do not have a background color. However, if the same image is used with the <img> tag, it renders correctly without any background color.

image | image

Here is GitHub link https://github.com/vinoddotcom/nuxt-svg-img-issue

run 1. num i 2. nmp run dev

vinoddotcom avatar Jun 13 '23 10:06 vinoddotcom

This is likely caused by ipx's transform of svgs.

cc: @pi0

danielroe avatar Jun 14 '23 11:06 danielroe

@danielroe any update on this issue?

Himanshu21git avatar Jul 01 '23 06:07 Himanshu21git

I think we should probably consider disabling ipx transformation for .svg as I can't imagine a situation where this is more performant. Thoughts @pi0?

danielroe avatar Jul 03 '23 11:07 danielroe

@danielroe any update on this issue?

vinoddotcom avatar Jul 18 '23 10:07 vinoddotcom

@danielroe The issue still exists, unable to move to the newer versions of nuxt-image because of this. Please help with this.

Himanshu21git avatar Jul 31 '23 06:07 Himanshu21git

+1

matsn0w avatar Nov 01 '23 10:11 matsn0w

@danielroe @pi0 Is there any new information or development regarding this?

Himanshu21git avatar Dec 12 '23 06:12 Himanshu21git

Issue Description:

I have encountered the same issue when using the nuxt-image module with SVG format images. The problem arises when we try to use nuxt-image for rendering svg images, The black background is visible in place of transparent area. Interestingly, this issue only occurs in stable versions of @nuxt/image module but does not persist in the edge channel version v1.0.0-27919678.2f5b64b.

Steps to Reproduce:

  1. Use the following syntax for nuxt-image with SVG format:
<nuxt-image format="svg" src="your-svg-image-path" />

Reproduce on Playground

  1. Observe the black background added to SVG images with transparent backgrounds.

Expected Behavior:

SVG images with transparent backgrounds should not have a black background added by default.

Additional Information:

  • The issue occurs on stable versions of @nuxt/image (i.e. v1.0.0 , v1.1.0).

  • The problem does not occur in the edge channel version v1.0.0-27919678.2f5b64b.

Possible Workaround:

If we remove the format prop to address the black background issue, SVG images are downloaded as JPEG instead of SVG.

Screenshots or Code Snippets:

image

Environment Information:

  • Nuxt.js version: 3.8.2
  • Nuxt Image module version: 1.1.0
  • Browser: chrome@latest
  • Operating System: ubuntu v22

Abdullah-In-Sync avatar Dec 12 '23 11:12 Abdullah-In-Sync