Compare commits

..

No commits in common. "e469c84d1beafdda3c11d2584e152f55d4aec7dc" and "8784f3baf994793067ae6151cd42c983a3f86f6a" have entirely different histories.

5 changed files with 21 additions and 4144 deletions

View file

@ -13,7 +13,9 @@ glitch art "framework", ???????? language??? something?
- zig at https://ziglang.org
- libc, lilv and libsndfile
- an appreciation for glitched anime girls on your hard drive
- graphicsmagick for the `rotate` command
- imagemagick for
- running the `rotate` command
- optional manual step: convert from whatever to bmp
## plugin depedencies:
- lv2 default plugins (most specifically the eg-amp plugin)

View file

@ -10,11 +10,17 @@ pub fn build(b: *Builder) void {
exe.linkSystemLibrary("sndfile");
exe.linkSystemLibrary("c");
exe.linkSystemLibrary("GraphicsMagickWand");
exe.linkSystemLibrary("GraphicsMagick");
// magick libraries
exe.linkSystemLibrary("MagickWand-7.Q16HDRI");
exe.linkSystemLibrary("MagickCore-7.Q16HDRI");
//exe.addArgs([_]u8{
// "-DMAGICKCORE_HDRI_ENABLE=1",
// "-DMAGICKCORE_QUANTUM_DEPTH=16",
//});
exe.addIncludeDir("/usr/include/lilv-0");
exe.addIncludeDir("/usr/include/GraphicsMagick");
exe.addIncludeDir("/usr/include/ImageMagick-7");
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());

View file

@ -340,7 +340,7 @@ pub const Image = struct {
}
pub fn saveTo(self: *Image, out_path: []const u8) !void {
std.debug.warn("\timg: copy from '{}' to '{}'\n", self.curpath, out_path);
std.debug.warn("saved to '{}'\n", out_path);
try std.fs.copyFile(self.curpath, out_path);
}

View file

@ -4,13 +4,15 @@ const images = @import("image.zig");
const Image = images.Image;
const mc = @import("magick_wand.zig");
const mc = @cImport({
@cInclude("MagickWand/MagickWand.h");
});
pub const MagickContext = struct {
wand: *mc.MagickWand,
pub fn init() !MagickContext {
mc.InitializeMagick(null);
mc.MagickWandGenesis();
var wand = mc.NewMagickWand();
if (wand == null) return error.WandCreateFail;
@ -22,7 +24,7 @@ pub const MagickContext = struct {
pub fn deinit(self: *MagickContext) void {
_ = mc.DestroyMagickWand(self.wand);
mc.DestroyMagick();
mc.MagickWandTerminus();
}
pub fn doErr(self: *MagickContext) !void {
@ -37,9 +39,7 @@ fn magickLoad(image: *Image) !MagickContext {
var curpath = try std.cstr.addNullByte(image.allocator, image.curpath);
defer image.allocator.free(curpath);
std.debug.warn("loading '{}'\n", curpath);
if (mc.MagickReadImage(mctx.wand, curpath.ptr) != 1)
if (mc.MagickReadImage(mctx.wand, curpath.ptr) == .MagickFalse)
return error.MagickReadFail;
return mctx;
@ -58,7 +58,7 @@ fn magickSave(image: *Image, mctx: *MagickContext) !void {
c_tmpnam,
);
if (mc.MagickWriteImage(mctx.wand, c_tmpnam.ptr) != 1)
if (mc.MagickWriteImages(mctx.wand, c_tmpnam.ptr, .MagickTrue) == .MagickFalse)
return error.MagickWriteFail;
}
@ -66,14 +66,7 @@ pub fn runRotate(image: *Image) !void {
var mctx = try magickLoad(image);
defer mctx.deinit();
var bg = mc.NewPixelWand().?;
defer mc.DestroyPixelWand(bg);
if (mc.PixelSetColor(bg, c"#ffffff") != 1)
return error.PixelSetColorFail;
if (mc.MagickRotateImage(mctx.wand, bg, 30) != 1)
return error.RotateFail;
// TODO run rotate here
try magickSave(image, &mctx);
}

File diff suppressed because it is too large Load diff