Compare commits
10 Commits
958e3f6bde
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| dfd8df0dd1 | |||
| eaf8c333e0 | |||
| 0b174a7e8a | |||
| f796041b2f | |||
| b92bed025f | |||
| b0f5154384 | |||
| b62c9f4e17 | |||
| a741f853c2 | |||
| 7029d040b2 | |||
| b4442b61fe |
10
.github/workflows/test-msys2.yaml
vendored
10
.github/workflows/test-msys2.yaml
vendored
@ -1,4 +1,4 @@
|
||||
name: Run tests on Windows
|
||||
name: Run tests on Windows (MSYS2)
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@ -14,12 +14,12 @@ jobs:
|
||||
- name: Install dependencies
|
||||
shell: C:\msys64\usr\bin\bash.exe --login '{0}'
|
||||
run: |
|
||||
export PATH="/mingw64/bin:$PATH"
|
||||
pacman --noconfirm -S mingw-w64-x86_64-imagemagick mingw-w64-x86_64-pkg-config
|
||||
export PATH="/ucrt64/bin:$PATH"
|
||||
pacman --noconfirm -S mingw-w64-ucrt-x86_64-imagemagick mingw-w64-ucrt-x86_64-pkg-config
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
with:
|
||||
cache-on-failure: true
|
||||
- name: Test
|
||||
run: |
|
||||
$env:PATH = "C:\msys64\usr\bin;C:\msys64\mingw64\bin;$env:PATH"
|
||||
cargo test -- --skip background --skip negate_image
|
||||
$env:PATH = "C:\msys64\usr\bin;C:\msys64\ucrt64\bin;$env:PATH"
|
||||
cargo test -- --skip test_set_background_color
|
||||
|
||||
@ -72,7 +72,7 @@ cd C:\IM7
|
||||
13. Search for "Edit the system environment variables" in the Start menu and click on "Environment Variables..."
|
||||
14. Add the following as system or user environment variables (replacing `C:\IM7` as appropriate):
|
||||
```ini
|
||||
IMAGE_MAGICK_DIR=C:\IM7\Output
|
||||
IMAGE_MAGICK_DIR=C:\IM7\Artifacts
|
||||
IMAGE_MAGICK_INCLUDE_DIRS=C:\IM7\ImageMagick
|
||||
```
|
||||
15. Add the following directory to your `PATH` variable:
|
||||
|
||||
20
build.rs
20
build.rs
@ -113,18 +113,14 @@ impl bindgen::callbacks::ParseCallbacks for RemoveEnumVariantSuffixes {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let check_cppflags = if cfg!(all(target_os = "windows", not(target_env = "msvc"))) {
|
||||
// Resolve bash from directories listed in the PATH environment variable in the
|
||||
// order they appear.
|
||||
Command::new("cmd")
|
||||
.arg("/C")
|
||||
.arg("bash")
|
||||
.arg("MagickCore-config")
|
||||
.arg("--cppflags")
|
||||
.output()
|
||||
} else {
|
||||
Command::new("MagickCore-config").arg("--cppflags").output()
|
||||
};
|
||||
let check_cppflags = Command::new("MagickCore-config")
|
||||
.arg("--cppflags")
|
||||
.output()
|
||||
.or_else(|_| {
|
||||
Command::new("pkg-config")
|
||||
.args(["--cflags", "MagickCore"])
|
||||
.output()
|
||||
});
|
||||
if let Ok(ok_cppflags) = check_cppflags {
|
||||
let cppflags = ok_cppflags.stdout;
|
||||
let cppflags = String::from_utf8(cppflags).unwrap();
|
||||
|
||||
33
examples/add-border.rs
Normal file
33
examples/add-border.rs
Normal file
@ -0,0 +1,33 @@
|
||||
extern crate magick_rust;
|
||||
use magick_rust::{magick_wand_genesis, CompositeOperator, MagickError, MagickWand, PixelWand};
|
||||
use std::fs;
|
||||
use std::sync::Once;
|
||||
|
||||
// Used to make sure MagickWand is initialized exactly once. Note that we do not
|
||||
// bother shutting down, we simply exit when we're done.
|
||||
static START: Once = Once::new();
|
||||
|
||||
// Read the named file and add a 10 pixel border around the image
|
||||
fn add_border(filepath: &str, border_color: &str) -> Result<Vec<u8>, MagickError> {
|
||||
START.call_once(|| {
|
||||
magick_wand_genesis();
|
||||
});
|
||||
|
||||
let wand = MagickWand::new();
|
||||
wand.read_image(filepath)?;
|
||||
|
||||
let mut border = PixelWand::new();
|
||||
border.set_color(border_color)?;
|
||||
|
||||
wand.border_image(&border, 10, 10, CompositeOperator::Over)?;
|
||||
wand.write_image_blob("jpeg")
|
||||
}
|
||||
|
||||
fn main() {
|
||||
match add_border("tests/fixtures/snow-covered-cat.jpg", "red") {
|
||||
Ok(bytes) => {
|
||||
fs::write("border-cat.jpg", bytes).expect("write failed");
|
||||
}
|
||||
Err(err) => println!("error: {}", err),
|
||||
}
|
||||
}
|
||||
@ -93,7 +93,7 @@ impl PixelWand {
|
||||
|
||||
set_get_unchecked!(
|
||||
get_color_count, set_color_count, PixelGetColorCount, PixelSetColorCount, usize
|
||||
get_index, set_index, PixelGetIndex, PixelSetIndex, f32
|
||||
get_index, set_index, PixelGetIndex, PixelSetIndex, bindings::Quantum
|
||||
get_fuzz, set_fuzz, PixelGetFuzz, PixelSetFuzz, f64
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user