v2ex / remote

Remote Worker
https://www.v2ex.com/go/dev
MIT License
80 stars 4 forks source link

Test for AVIF is not working in PR #26 #27

Closed livid closed 2 years ago

livid commented 2 years ago

With the current implementation, to recognize an image, it needs to be both recognized by libmagic and Pillow. And that caused test for AVIF to fail. Because while Pillow.Image can recognize it:

Screen Shot 2021-12-14 at 7 07 43 AM

But libmagic cannot:

Screen Shot 2021-12-14 at 7 08 15 AM

If Pillow.Image can return a meaningful result, libmagic should not block the process.

luxiaba commented 2 years ago

But libmagic cannot:

This line is logged by us, first i try to get mime by using magic, if magic can't get it or result is not in our supported-mime list(means we can't handle this kind of mime), i'll log this.

Actually, in the above case, application/octet-stream is result that mgaic get, magic guess mime type by the first few bytes of byte stream, same as PIL, but the types supported by PIL are limited, if PIL can recognize, magic should be able too.

It's a little strange. magic didn't get the correct mime from bytes content, i'll test and find out.

luxiaba commented 2 years ago

I test it by curl with cap.avif in repo, seesm normal.

image

livid commented 2 years ago

I guess you are testing on macOS.

Can you try Ubuntu or Debian?

livid commented 2 years ago

CI is now failing for the same reason:

https://github.com/v2ex/remote/actions/runs/1578163584

luxiaba commented 2 years ago

Sure, let me create on first😂

luxiaba commented 2 years ago

Seems magic not support avif now, but pillow-avif-plugin allows PIL to handle avif. image

If magic gets the valid mime then use it, otherwise try to get mime by using PIL, how about that?

luxiaba commented 2 years ago

Maybe there is a component in my macOS that supports magic to handle avif.🤔 image

livid commented 2 years ago

It seems Magic on macOS can recognize it. But the production server is running Debian with Docker.

Yes, we need to turn these tests green. Thanks!