Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Use ImageMagick's magick.exe if convert.exe is not installed #11847

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

Merged
merged 1 commit into from
Aug 19, 2018
Merged

Use ImageMagick's magick.exe if convert.exe is not installed #11847

merged 1 commit into from
Aug 19, 2018

Conversation

cgohlke
Copy link
Contributor

@cgohlke cgohlke commented Aug 13, 2018

PR Summary

On Windows, ImageMagick >= 7 does not include convert.exe by default. Instead the converter is built into magick.exe.

Fixes #11792

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

On Windows, ImageMagick >= 7 does not include convert.exe by default. Instead the converter is built into magick.exe.
@fredrik-1
Copy link
Contributor

fredrik-1 commented Aug 13, 2018

I am not completely sure that this is the correct thing to do but it would make it easier for many people on windows to use imagemagick so I think that I am positive.

What about first testing magick with shutil.which('magick') and then path + magick to avoid adding a long path to bin_path when it is not necessary?

Are there cases when it exist a magick.exe that doesn't do the same thing as convert.exe? If not I would suggest to first test magick then path+convert.exe and last path+magick.exe

@cgohlke
Copy link
Contributor Author

cgohlke commented Aug 13, 2018

What about first testing magick with shutil.which('magick') and then path + magick to avoid adding a long path to bin_path when it is not necessary?

This PR just fixes the existing functionality (initializing mpl settings from the registry settings created by ImageMagick installers on Windows) for the ImageMagick >= 7.

Using a magick executable found in the executable search path seems like a good idea to add, but probably not in this PR and not Windows only (?).

@fredrik-1
Copy link
Contributor

I think that it would fit into this pr but it is not that important either. I just think that it would be better to change the rcparameter to magick instead of long path + magick.exe when that is the way you would do it manually (if the path is set but the default settings assumes that anyway).

Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Further discussion about whether to first try convert or magick can happen later.

@timhoffm
Copy link
Member

Thanks!

@timhoffm
Copy link
Member

Would this still be eligible for 3.0, or should it go in 3.1?

@ImportanceOfBeingErnest
Copy link
Member

Is it assured that when you install imagemagick > 7 on other systems (linux, mac) that they always install a convert?

@anntzer
Copy link
Contributor

anntzer commented Aug 14, 2018

At least https://www.imagemagick.org/script/porting.php documents that "To reduce the footprint of the command-line utilities, these utilities [convert, etc.] are symbolic links to the magick utility. You can also invoke them from the magick utility, for example, use magick convert logo: logo.png to invoke the convert utility."
(In fact, this leads to the question of why these utilities are not present on Windows.)

Let's milestone this for 3.0 and ping @tacaswell for the final decision.

@anntzer anntzer added this to the v3.0 milestone Aug 14, 2018
@cgohlke
Copy link
Contributor Author

cgohlke commented Aug 14, 2018

In fact, this leads to the question of why these utilities are not present on Windows

These are considered legacy utilities. There's an option in the ImageMagick >= 7 installer (disabled by default) to install the utilities.

@ImportanceOfBeingErnest
Copy link
Member

This option is disabled by default, so most users will not check it.

image

So my question is essentially: Does a similar "installation" process happen for Linux / Mac such that people could end up with Imagemagick without convert binary?

@anntzer
Copy link
Contributor

anntzer commented Aug 14, 2018

@cgohlke My point is that the porting docs don't even mention the fact that they may not be installed. But that's not particularly relevant as we're stuck with the actual behavior on Windows anyways.

@ImportanceOfBeingErnest Most Linux users would get imagemagick from their distro packages. Arch Linux packages IM7 including the "convert" command. None of Fedora (28), Debian (unstable), Ubuntu (18.04) appear to even package IM7 at all. So in practice that means that anyone who has IM7 without a "convert" command likely compiled IM themselves -- I wouldn't worry too much about that case.

@QuLogic
Copy link
Member

QuLogic commented Aug 14, 2018

Many Linux distros didn't upgrade to IM7 specifically because of the lack of the old executables.

@jklymak
Copy link
Member

jklymak commented Aug 18, 2018

I'd merge this as fixing a problem, and defer the discussion of a more general fix to someone finding that to be a problem. However, I don't have a PC, and can't test that this actually works, and it has no test coverage. If other reviewers are sure it works and don't think it needs test coverage, they should feel free to merge.

@tacaswell tacaswell merged commit 799ab40 into matplotlib:master Aug 19, 2018
@tacaswell
Copy link
Member

@meeseeksdev backport to v2.2.x

@lumberbot-app
Copy link

lumberbot-app bot commented Aug 19, 2018

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v2.2.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 799ab40a13957e5c5aba8a69686791263e33f6f9
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am "Backport PR #11847: Use ImageMagick's magick.exe if convert.exe is not installed"
  1. Push to a named branch :
git push YOURFORK v2.2.x:auto-backport-of-pr-11847-on-v2.2.x
  1. Create a PR against branch v2.2.x, I would have named this PR:

"Backport PR #11847 on branch v2.2.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

QuLogic added a commit that referenced this pull request Aug 19, 2018
@dstansby dstansby modified the milestones: v3.0.0, v3.1.0 Jun 7, 2019
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

Successfully merging this pull request may close these issues.

Newer versions of ImageMagickWriter not found on windows
9 participants