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

__load_from_output_folder fails on MacOS because of .DS_Store file #9

Closed
maephisto666 opened this issue Mar 21, 2018 · 7 comments
Closed

Comments

@maephisto666
Copy link

On MacOS, whenever we use

  • convert_from_path
  • convert_from_bytes

functions, if we pass an output_folder they end up calling __load_from_output_folder function.

If we use an existing folder, already visited with the Finder app, the function fails saying that .DS_Store is not a valid image.

The problem is that this file is created automatically by MacOS Finder app. My suggestion if that this can be fixed passing a list of files to be ignored. If you agree, I can make the pull request.

@Belval
Copy link
Owner

Belval commented Mar 21, 2018

Instead I would fix it by wrapping the image load call into a try/except to ignore non-image. It would be more pythonic and avoid having to maintain a file blacklist.

I'll push a fix right now.

@Belval
Copy link
Owner

Belval commented Mar 21, 2018

I looked into it and I'll just ignore files that start with a '.' that way any hidden file won't be processed.

@Belval
Copy link
Owner

Belval commented Mar 21, 2018

See 8153911 does this solution solve your problem?

@maephisto666
Copy link
Author

Partly. This way we are assuming that the output_folder is always a fresh one. Otherwise:

  • if it contains other images, they will be returned as part of the result of the current call;
  • if it contains other files (e.g. pdf files) not starting with a '.', we will get the error as well.

@Belval
Copy link
Owner

Belval commented Mar 21, 2018

Points taken, pdf2image should not expect the folder to be empty. I will fix this by having a unique identifier in every generated image so the folder will not matter as long as you have the required permissions.

@Belval
Copy link
Owner

Belval commented Mar 22, 2018

So f2b5b1b

It fixes your problem by exclusively considering images generated by pdftoppm in the function call you made. You can now use and reuse the same folder (without cleaning it if you want) and it will not throw.

Please tell me if that solve your problem.

@maephisto666
Copy link
Author

Well, it helps.
I left two comments in the commit.

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

No branches or pull requests

2 participants