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:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@ -14,12 +14,12 @@ jobs:
|
|||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
shell: C:\msys64\usr\bin\bash.exe --login '{0}'
|
shell: C:\msys64\usr\bin\bash.exe --login '{0}'
|
||||||
run: |
|
run: |
|
||||||
export PATH="/mingw64/bin:$PATH"
|
export PATH="/ucrt64/bin:$PATH"
|
||||||
pacman --noconfirm -S mingw-w64-x86_64-imagemagick mingw-w64-x86_64-pkg-config
|
pacman --noconfirm -S mingw-w64-ucrt-x86_64-imagemagick mingw-w64-ucrt-x86_64-pkg-config
|
||||||
- uses: Swatinem/rust-cache@v2
|
- uses: Swatinem/rust-cache@v2
|
||||||
with:
|
with:
|
||||||
cache-on-failure: true
|
cache-on-failure: true
|
||||||
- name: Test
|
- name: Test
|
||||||
run: |
|
run: |
|
||||||
$env:PATH = "C:\msys64\usr\bin;C:\msys64\mingw64\bin;$env:PATH"
|
$env:PATH = "C:\msys64\usr\bin;C:\msys64\ucrt64\bin;$env:PATH"
|
||||||
cargo test -- --skip background --skip negate_image
|
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..."
|
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):
|
14. Add the following as system or user environment variables (replacing `C:\IM7` as appropriate):
|
||||||
```ini
|
```ini
|
||||||
IMAGE_MAGICK_DIR=C:\IM7\Output
|
IMAGE_MAGICK_DIR=C:\IM7\Artifacts
|
||||||
IMAGE_MAGICK_INCLUDE_DIRS=C:\IM7\ImageMagick
|
IMAGE_MAGICK_INCLUDE_DIRS=C:\IM7\ImageMagick
|
||||||
```
|
```
|
||||||
15. Add the following directory to your `PATH` variable:
|
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() {
|
fn main() {
|
||||||
let check_cppflags = if cfg!(all(target_os = "windows", not(target_env = "msvc"))) {
|
let check_cppflags = Command::new("MagickCore-config")
|
||||||
// Resolve bash from directories listed in the PATH environment variable in the
|
.arg("--cppflags")
|
||||||
// order they appear.
|
.output()
|
||||||
Command::new("cmd")
|
.or_else(|_| {
|
||||||
.arg("/C")
|
Command::new("pkg-config")
|
||||||
.arg("bash")
|
.args(["--cflags", "MagickCore"])
|
||||||
.arg("MagickCore-config")
|
.output()
|
||||||
.arg("--cppflags")
|
});
|
||||||
.output()
|
|
||||||
} else {
|
|
||||||
Command::new("MagickCore-config").arg("--cppflags").output()
|
|
||||||
};
|
|
||||||
if let Ok(ok_cppflags) = check_cppflags {
|
if let Ok(ok_cppflags) = check_cppflags {
|
||||||
let cppflags = ok_cppflags.stdout;
|
let cppflags = ok_cppflags.stdout;
|
||||||
let cppflags = String::from_utf8(cppflags).unwrap();
|
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!(
|
set_get_unchecked!(
|
||||||
get_color_count, set_color_count, PixelGetColorCount, PixelSetColorCount, usize
|
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
|
get_fuzz, set_fuzz, PixelGetFuzz, PixelSetFuzz, f64
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user