magick: reopen the file instead of just setting curpath
This commit is contained in:
parent
c128960451
commit
c0b70a81b1
|
@ -221,6 +221,16 @@ pub const Image = struct {
|
||||||
return seek_pos;
|
return seek_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn reopen(self: *Image, path: []const u8) !void {
|
||||||
|
var in_fmt = mkSfInfo();
|
||||||
|
|
||||||
|
self.sndfile = try sopen(self.allocator, path, c.SFM_READ, &in_fmt);
|
||||||
|
self.curpath = path;
|
||||||
|
self.frames = @intCast(usize, in_fmt.frames);
|
||||||
|
|
||||||
|
std.debug.warn("\timage: reopened on '{}'\n", self.curpath);
|
||||||
|
}
|
||||||
|
|
||||||
/// Run a plugin over the image.
|
/// Run a plugin over the image.
|
||||||
/// This setups a new lilv world/plugin among other things.
|
/// This setups a new lilv world/plugin among other things.
|
||||||
/// The internal SNDFILE pointer is modified to point to the output of the
|
/// The internal SNDFILE pointer is modified to point to the output of the
|
||||||
|
@ -334,9 +344,7 @@ pub const Image = struct {
|
||||||
_ = c.sf_close(out_file);
|
_ = c.sf_close(out_file);
|
||||||
_ = c.sf_close(self.sndfile);
|
_ = c.sf_close(self.sndfile);
|
||||||
|
|
||||||
// reopen the file as SFM_READ so we can run plugin chains etc
|
try self.reopen(tmpnam);
|
||||||
self.sndfile = try sopen(self.allocator, tmpnam, c.SFM_READ, &out_fmt);
|
|
||||||
self.curpath = tmpnam;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn saveTo(self: *Image, out_path: []const u8) !void {
|
pub fn saveTo(self: *Image, out_path: []const u8) !void {
|
||||||
|
@ -414,7 +422,6 @@ pub const Image = struct {
|
||||||
_ = c.sf_close(self.sndfile);
|
_ = c.sf_close(self.sndfile);
|
||||||
|
|
||||||
// reopen the file as SFM_READ so we can run plugin chains etc
|
// reopen the file as SFM_READ so we can run plugin chains etc
|
||||||
self.sndfile = try sopen(self.allocator, tmpnam, c.SFM_READ, &out_fmt);
|
try self.reopen(tmpnam);
|
||||||
self.curpath = tmpnam;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -57,7 +57,7 @@ fn magickSave(image: *Image, wand: *mc.MagickWand) !void {
|
||||||
if (mc.MagickWriteImage(wand, c_tmpnam.ptr) != 1)
|
if (mc.MagickWriteImage(wand, c_tmpnam.ptr) != 1)
|
||||||
return error.MagickWriteFail;
|
return error.MagickWriteFail;
|
||||||
|
|
||||||
image.curpath = tmpnam;
|
try image.reopen(tmpnam);
|
||||||
std.debug.warn("OK\n");
|
std.debug.warn("OK\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue