Compare commits

10 Commits

Author SHA1 Message Date
dfd8df0dd1 Merge pull request #138 from gyk/fix/msys2
Remove Windows-specific invocation of MagickCore-config
2024-09-18 21:17:50 -07:00
eaf8c333e0 Switch from mingw64 to ucrt64 2024-09-18 15:35:49 +08:00
0b174a7e8a Remove Windows-specific invocation of MagickCore-config 2024-09-18 11:16:29 +08:00
f796041b2f Merge pull request #132 from Des-Nerger/master
Add pkg-config as fallback for MagickCore-config
2024-08-26 21:44:35 -07:00
b92bed025f Add pkg-config as fallback for MagickCore-config
Fixes nlfiedler/magick-rust#131
2024-08-26 12:59:06 +10:00
b0f5154384 Merge pull request #130 from amanao/amanao/update-install-md
Update directory name in Windows installation instructions
2024-08-17 15:00:52 -07:00
b62c9f4e17 Update directory name in Windows installation instructions 2024-08-15 12:02:26 +09:00
a741f853c2 Merge pull request #127 from timotk/add-border-example
Add an example to add a border
2024-08-07 20:16:19 -07:00
7029d040b2 Fix path 2024-08-07 16:03:40 +02:00
b4442b61fe Add an example to add a border 2024-08-07 16:00:39 +02:00
5 changed files with 48 additions and 19 deletions

View File

@ -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

View File

@ -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:

View File

@ -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
View 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),
}
}

View File

@ -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
); );