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

Bug:failed generate png picture thumbnail but some others succeed #268

Open
hatcherfang opened this issue Aug 27, 2021 · 8 comments
Open
Labels

Comments

@hatcherfang
Copy link

hatcherfang commented Aug 27, 2021

Description and expectations

I generate some png files' thumbnail failed, but some others succeed when I use the manager.get_jpeg_preview.

How to reproduce

from preview_generator.manager import PreviewManager


path = '/tmp/IMG20200422_094758.png'                                                  
cache_path = "/tmp/cache/"                                                            
manager = PreviewManager(cache_path, create_folder=True)                              
path_to_preview_image = manager.get_jpeg_preview(path, force=True)

the image as below:
IMG20200422_094758

but the other image is ok as below:
huizhang

Version information

  • Version: [0.23]
  • Device / System: [Debian Buster]
@hatcherfang hatcherfang changed the title Bug:failed generate some png files' thumbnail Bug:failed generate png picture thumbnail fail but some others succeed Aug 27, 2021
@hatcherfang hatcherfang changed the title Bug:failed generate png picture thumbnail fail but some others succeed Bug:failed generate png picture thumbnail but some others succeed Aug 27, 2021
@raphj
Copy link
Contributor

raphj commented Aug 27, 2021

Is there an error message?

@hatcherfang
Copy link
Author

hatcherfang commented Aug 27, 2021

Is there an error message?
Yes, the error message is as below:

  File "test3.py", line 7, in <module>
    path_to_preview_image = manager.get_jpeg_preview(path, force=True)
  File "/usr/local/lib/python3.6/site-packages/preview_generator/manager.py", line 203, in get_jpeg_preview
    mimetype=preview_context.mimetype,
  File "/usr/local/lib/python3.6/site-packages/preview_generator/preview/builder/image__imconvert.py", line 131, in build_jpeg_preview
    source_path=file_path, dest_path=tmp_png.name, mimetype=mimetype
  File "/usr/local/lib/python3.6/site-packages/preview_generator/preview/builder/image__imconvert.py", line 164, in _imagemagick_convert
    stderr=STDOUT,
  File "/usr/local/lib/python3.6/subprocess.py", line 311, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['convert', 'png:/tmp/IMG20200422_094758.png', '-layers', 'merge', '/tmp/preview-generator-y7qu4wdy.png']' returned non-zero exit status 1.

@Felti
Copy link

Felti commented Sep 6, 2021

i got the same error for PNG some get converted and some not

@raphj
Copy link
Contributor

raphj commented Sep 6, 2021

What happens if you run the given convert command manually? Is there a meaningful error?

convert png:/tmp/IMG20200422_094758.png -layers merge /tmp/preview-generator-y7qu4wdy.png

@Felti
Copy link

Felti commented Sep 6, 2021

i did some tests, it appear that when the image have been converted to something other than it's original extension, it triggers the errors, must be something related to the mimeType check (ex : .png , image/jpg), otherwise when the file/img extension is the same as the mimeType (ex : .png , image/png) it doesn't

@raphj
Copy link
Contributor

raphj commented Sep 6, 2021

So you run into errors when attempting to preview a .png file which is actually a JPEG image, is that it? Do I understand correctly?

@hatcherfang is /tmp/IMG20200422_094758.png indeed a PNG image or is it actually a JPG image? GitHub actually did a jpeg preview for your image.

@Felti
Copy link

Felti commented Sep 6, 2021

So you run into errors when attempting to preview a .png file which is actually a JPEG image, is that it? Do I understand correctly?

yes indeed

@raphj
Copy link
Contributor

raphj commented Sep 6, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants