v2ex/remote

Test for AVIF is not working in PR #26

livid opened this issue · 8 comments

livid commented

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.

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.

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

image

livid commented

I guess you are testing on macOS.

Can you try Ubuntu or Debian?

livid commented

CI is now failing for the same reason:

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

Sure, let me create on first😂

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?

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

livid commented

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!