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

to_image() method does not take extra arguments #75

Closed
OisinMoran opened this issue Aug 5, 2018 · 2 comments
Closed

to_image() method does not take extra arguments #75

OisinMoran opened this issue Aug 5, 2018 · 2 comments

Comments

@OisinMoran
Copy link
Contributor

First of all, I'd just like to thank you so much for this incredible tool!

In the README it is stated that the to_image() method takes conversion_kwargs and links to this which has parameters such as background, yet the only parameter it actually seems to take is resolution. This leads to errors such as to_image() got an unexpected keyword argument 'background' when attempting to change the default background. Am I doing something wrong or does the documentation not quite match up with the functionality? If so is there a work-around or if not I'd be more than happy to contribute to try and add this functionality.

README

Method Description
.to_image(**conversion_kwargs) Returns an instance of the PageImage class. For more details, see "Visual debugging" below. For conversion_kwargs, see here.

Function

    def to_image(self, resolution=None):
        """
        For conversion_kwargs, see http://docs.wand-py.org/en/latest/wand/image.html#wand.image.Image
        """
        from .display import PageImage, DEFAULT_RESOLUTION
        res = resolution or DEFAULT_RESOLUTION
        return PageImage(self, resolution=res)
@jsvine
Copy link
Owner

jsvine commented Sep 11, 2018

Hi @OisinMoran, and thank you for flagging this! That does seem to be a bug. I'll aim to fix it in a future release. In the meantime, I think you should be able fix it locally by changing that function to the following:

    def to_image(self, **conversion_kwargs):
        """
        For conversion_kwargs, see http://docs.wand-py.org/en/latest/wand/image.html#wand.image.Image
        """
        from .display import PageImage, DEFAULT_RESOLUTION
        kwargs = dict(conversion_kwargs)
        if "resolution" not in conversion_kwargs:
            kwargs["resolution"] = DEFAULT_RESOLUTION
        return PageImage(self, **kwargs)

Does that fix the bug for you?

@jsvine
Copy link
Owner

jsvine commented Nov 14, 2018

Should be fixed in v0.5.11! Feel free to re-open this issue, though, if the problem persists for you.

@jsvine jsvine closed this as completed Nov 14, 2018
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