Save IR plot in same directory as IR file with matching filename
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"math/cmplx"
|
"math/cmplx"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"image/png"
|
"image/png"
|
||||||
|
|
||||||
@@ -642,8 +643,13 @@ func PlotIR(ir []float64, sampleRate int, irFileName string) error {
|
|||||||
p2.Draw(canvases[1][0])
|
p2.Draw(canvases[1][0])
|
||||||
dc.DrawImage(vg.Rectangle{Min: vg.Point{X: 0, Y: 0}, Max: vg.Point{X: width, Y: height}}, imgPlots.Image())
|
dc.DrawImage(vg.Rectangle{Min: vg.Point{X: 0, Y: 0}, Max: vg.Point{X: width, Y: height}}, imgPlots.Image())
|
||||||
|
|
||||||
// Save as PNG
|
// Save as PNG in the same directory as the IR file
|
||||||
f, err = os.Create("ir_plot.png")
|
irDir := filepath.Dir(irFileName)
|
||||||
|
irBase := filepath.Base(irFileName)
|
||||||
|
irNameWithoutExt := strings.TrimSuffix(irBase, filepath.Ext(irBase))
|
||||||
|
plotFileName := filepath.Join(irDir, irNameWithoutExt+".png")
|
||||||
|
|
||||||
|
f, err = os.Create(plotFileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user