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

Image component change animated files to static ones #34807

Closed
1 task done
jukialen opened this issue Feb 25, 2022 · 10 comments · Fixed by #35120
Closed
1 task done

Image component change animated files to static ones #34807

jukialen opened this issue Feb 25, 2022 · 10 comments · Fixed by #35120
Assignees
Labels
Image (next/image) Related to Next.js Image Optimization.

Comments

@jukialen
Copy link

jukialen commented Feb 25, 2022

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

'yarn' is not recognized as an internal or external command,
operable program or batch file.
'pnpm' is not recognized as an internal or external command,
operable program or batch file.

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Home
Binaries:
  Node: 14.18.1
  npm: 7.20.3
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 12.1.0
  react: 17.0.2
  react-dom: 17.0.2

What browser are you using? (if relevant)

All main web browsers except Safari (I don't have Safari).

How are you deploying your application? (if relevant)

No response

Describe the Bug

I have a component for animited photos and I use . When this one show animated photo, I have static one, but when I change on , the files are animited (e. g. eyes are moving).

For example: https://pronama.jp/images/animated.png

Expected Behavior

When Image get animited files (apng, gif or animited webp and avif), Image should know this isn't static photo, yet animited one, so files should move. That files should be converting to avif or webp when web browser support that formats, especially gif format.

Gif format must be converted to avif, webp or apng format by the performance of that format.

To Reproduce

I change to img tag: it work.
I added "unoptimized": it work too.
I added Image without unoptimized: it doesn't work.

I wanted to add apng or gif format in next.config file, but I get the same errors:"
Error: Specified images.formats must be length 1 or 2, received length (3), please reduce the length of the array to continue.

or

Error: Specified images.formats should be an Array of mime type strings, received invalid values (image/apng).
"
"image/apng" is in headers request.

My components for images: https://github.com/jukialen/portal_for_artists_in_next/blob/main/components/atoms/Photos/Photos.tsx
My next.config:
https://github.com/jukialen/portal_for_artists_in_next/blob/main/next.config.js

@jukialen jukialen added the bug Issue was opened via the bug report template. label Feb 25, 2022
@balazsorban44 balazsorban44 added the Image (next/image) Related to Next.js Image Optimization. label Mar 3, 2022
@styfle styfle self-assigned this Mar 7, 2022
@styfle styfle added kind: bug and removed bug Issue was opened via the bug report template. labels Mar 7, 2022
@styfle
Copy link
Member

styfle commented Mar 7, 2022

We normally detect animated images and bypass optimization.

This will be fixed in PR #35120 so you won't need to add unoptimized prop anymore, thanks!

@kodiakhq kodiakhq bot closed this as completed in #35120 Mar 7, 2022
kodiakhq bot pushed a commit that referenced this issue Mar 7, 2022
- Fixes #34807
- Related commit qzb/is-animated@69dad3c

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
@styfle
Copy link
Member

styfle commented Mar 7, 2022

The fix is available on the canary channel.

You can try it out with npm i next@canary or yarn add next@canary, thanks!

@jukialen
Copy link
Author

jukialen commented Mar 7, 2022

We normally detect animated images and bypass optimization.

This will be fixed in PR #35120 so you won't need to add unoptimized prop anymore, thanks!

What animation file formats are supported?

@styfle
Copy link
Member

styfle commented Mar 7, 2022

Next.js will automatically detect gif, apng, webp via is-animated

However, if you know an image is animated its probably best to explicitly set the unoptimized prop.

@Yuripetusko
Copy link
Contributor

Hm we tested the canary version and apng are still not animated unless we explicitly set unoptimized

@nikitindiz
Copy link

Hm we tested the canary version and apng are still not animated unless we explicitly set unoptimized

next@canary

https://github.com/nikitindiz/nextjs-apng-bug

https://nextjs-apng-bug.vercel.app/

Left one - optimized, both images should be animated.

@styfle
Copy link
Member

styfle commented Mar 24, 2022

Thanks for reporting! It looks likes it working with next start but not on Vercel deployments. We'll get that fixed shortly 👍

In the meantime, manually setting the unoptimized prop is the best workaround.

@jukialen
Copy link
Author

Next.js will automatically detect gif, apng, webp via is-animated

However, if you know an image is animated its probably best to explicitly set the unoptimized prop.

I did this and it work, but good is hear that it will have is-animated.

@jukialen
Copy link
Author

jukialen commented Mar 25, 2022

@styfle When I had canary version, I had to use unoptimized in order to it work (not only first next start), so this isn't problem in the Vercel.

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Image (next/image) Related to Next.js Image Optimization.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants