feat: inline conversion with status updates, cwebp support, v0.1.4
- Conversion now happens inline on the file list — status column updates from idle → converting... → done/error in place (no separate screen) - Fixed value-receiver bug in convertNext() that prevented 'converting' status from being displayed - Added cwebp fallback for PNG/JPEG → WebP (ffmpeg webp encoder often missing on macOS) - Format selector arrows hidden during conversion/results states - Simplified to 2 states: stateFileList + stateResults - Added tests for conversion state machine and view rendering
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"image/jpeg"
|
||||
"image/png"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/image/bmp"
|
||||
@@ -88,6 +89,17 @@ func tryDecodeImage(f *os.File, path string) (image.Image, error) {
|
||||
}
|
||||
|
||||
func convertImageViaFFmpeg(inputPath, outputPath, format string) error {
|
||||
// For WebP: prefer cwebp (from libwebp-tools) which is widely available
|
||||
if format == "webp" {
|
||||
if cwebpPath, err := exec.LookPath("cwebp"); err == nil {
|
||||
cmd := exec.Command(cwebpPath, "-q", "90", inputPath, "-o", outputPath)
|
||||
if out, err := cmd.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("cwebp error: %w\n%s", err, string(out))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
args := []string{"-y", "-i", inputPath}
|
||||
|
||||
switch format {
|
||||
|
||||
Reference in New Issue
Block a user