fix: make disable-hdri default to fix compile error

By making the disable-hdri feature a default, the `quantum_range()` function
will be one which computes a value for `QuantumRange` based on a constant
that rust-bindgen seemingly does not have any problem discovering.

cargo test passes
This commit is contained in:
Nathan Fiedler
2023-09-23 11:43:07 -07:00
parent ef1867e9f9
commit 8a9536d83a
4 changed files with 11 additions and 27 deletions

View File

@ -5,6 +5,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
This file follows the convention described at This file follows the convention described at
[Keep a Changelog](http://keepachangelog.com/en/1.0.0/). [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
## [Unreleased]
### Changed
- Feature `disable-hdri` is now enabled by default to work around an apparent
bug with rust-bindgen that cannot discover the `QuantumRange` constant which
is conditionally computed during compile-time in the MagickCore library.
## [0.19.0] - 2023-06-19 ## [0.19.0] - 2023-06-19
### Added ### Added
- walterbm: Add `coalesce()` for image coalesce. - walterbm: Add `coalesce()` for image coalesce.
@ -49,7 +55,7 @@ This file follows the convention described at
- liyunde: Fix path_separator on windows can not build - liyunde: Fix path_separator on windows can not build
- kz6wk9: Required version bump on bindgen. - kz6wk9: Required version bump on bindgen.
- asonix: Set environment variable with magickcore config flags - asonix: Set environment variable with magickcore config flags
- captainbland: Add workaround for QuantumRange not defined error when hdri is disabled - captainbland: Add workaround for `QuantumRange` not defined error when hdri is disabled
## [0.14.0] - 2020-05-21 ## [0.14.0] - 2020-05-21
### Added ### Added

View File

@ -18,5 +18,8 @@ bindgen = "0.68.1"
pkg-config = "0.3" pkg-config = "0.3"
[features] [features]
# Work-around for bindgen(?) not finding the QuantumRange definition ever since
# MagickWand 7.1.1.17 (or .16) when this suddenly stopped working.
default = ["disable-hdri"]
# Workaround for bindgen bug when ImageMagick is compiled with disable-hdri # Workaround for bindgen bug when ImageMagick is compiled with disable-hdri
disable-hdri = [] disable-hdri = []

View File

@ -42,29 +42,6 @@ When building on Windows, you will need to set the `IMAGE_MAGICK_DIR` environmen
> cargo test > cargo test
``` ```
### Build Troubleshooting
#### Error: cannot find value `QuantumRange` in module bindings
When attempting to build the library, you might see an error like this one:
```
error[E0425]: cannot find value `QuantumRange` in module `bindings`
--> C:\Users\charlie\.cargo\registry\src\github.com-1ecc6299db9ec823\magick_rust-0.9.0\src\wand\magick.rs:337:80
|
337 | if bindings::MagickSepiaToneImage(self.wand, threshold * bindings::QuantumRange) == bindings::MagickBooleanType::MagickTrue {
|
^^^^^^^^^^^^ not found in `bindings`
error: aborting due to previous error
```
See [issue 40](https://github.com/nlfiedler/magick-rust/issues/40) on GitHub for some background. The issue seems to be that with HDRI disabled, rust-bindgen will not produce the bindings needed for the "quantum range" feature of ImageMagick (see [issue 316](https://github.com/rust-lang/rust-bindgen/issues/316)). To work-around this issue, you can disable HDRI support in your `Cargo.toml` file, like so:
```
magick_rust = { version = "0.18.0", features = ["disable-hdri"] }
```
## Documentation ## Documentation
The API documentation is available at [github pages](https://nlfiedler.github.io/magick-rust) since the docs.rs system has a hard time building anything that requires an external library that is not wrapped in a "sys" style library. See [issue 57](https://github.com/nlfiedler/magick-rust/issues/57) for the "create a sys crate request." The API documentation is available at [github pages](https://nlfiedler.github.io/magick-rust) since the docs.rs system has a hard time building anything that requires an external library that is not wrapped in a "sys" style library. See [issue 57](https://github.com/nlfiedler/magick-rust/issues/57) for the "create a sys crate request."

View File

@ -350,9 +350,7 @@ impl MagickWand {
16 => Ok(65535.0f64), 16 => Ok(65535.0f64),
32 => Ok(4294967295.0f64), 32 => Ok(4294967295.0f64),
64 => Ok(18446744073709551615.0f64), 64 => Ok(18446744073709551615.0f64),
_ => Err(MagickError( _ => Err(MagickError("Quantum depth must be one of 8, 16, 32 or 64")),
("Quantum depth must be one of 8, 16, 32 or 64"),
)),
} }
} }