image-video-optimizer 3.0.1 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/imageProcessor.js +6 -1
- package/src/videoProcessor.js +9 -8
package/package.json
CHANGED
package/src/imageProcessor.js
CHANGED
|
@@ -47,8 +47,13 @@ async function processImage(imagePath, config) {
|
|
|
47
47
|
image = image.png({ compressionLevel: 9 });
|
|
48
48
|
} else if (outputFormat === 'webp') {
|
|
49
49
|
image = image.webp({ quality: 80 });
|
|
50
|
+
} else if (outputFormat === 'gif') {
|
|
51
|
+
image = image.gif();
|
|
52
|
+
} else if (outputFormat === 'tiff') {
|
|
53
|
+
image = image.tiff();
|
|
50
54
|
} else {
|
|
51
|
-
|
|
55
|
+
// Default to jpeg for unknown formats
|
|
56
|
+
image = image.jpeg({ quality: 80, progressive: true });
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
// Write to temporary file
|
package/src/videoProcessor.js
CHANGED
|
@@ -45,8 +45,7 @@ async function processVideo(videoPath, config) {
|
|
|
45
45
|
.size(`${config.video_max_width}x?`)
|
|
46
46
|
.outputOptions([
|
|
47
47
|
'-preset fast',
|
|
48
|
-
'-crf 28'
|
|
49
|
-
'-c:a aac' // Use AAC for audio (widely compatible)
|
|
48
|
+
'-crf 28'
|
|
50
49
|
])
|
|
51
50
|
.output(tmpPath);
|
|
52
51
|
|
|
@@ -102,14 +101,16 @@ async function processVideo(videoPath, config) {
|
|
|
102
101
|
let errorMsg = err.message;
|
|
103
102
|
|
|
104
103
|
// Provide helpful suggestions for common errors
|
|
105
|
-
if (err.message.includes('Unknown encoder') || err.message.includes('Encoder')) {
|
|
106
|
-
errorMsg = `
|
|
107
|
-
} else if (err.message.includes('
|
|
108
|
-
errorMsg = `
|
|
104
|
+
if (err.message.includes('Unknown encoder') || err.message.includes('Encoder (')) {
|
|
105
|
+
errorMsg = `Codec "${outputCodec}" not supported. Try: video_encode=h264`;
|
|
106
|
+
} else if (err.message.includes('No such file') || err.message.includes('does not exist')) {
|
|
107
|
+
errorMsg = `Input file not found or cannot be read`;
|
|
109
108
|
} else if (err.message.includes('ENOENT') || err.message.includes('ffmpeg')) {
|
|
110
|
-
errorMsg = `FFmpeg not found. Install with: brew install ffmpeg
|
|
109
|
+
errorMsg = `FFmpeg not found. Install with: brew install ffmpeg`;
|
|
111
110
|
} else if (err.message.includes('Conversion failed') || err.message.includes('exited with code')) {
|
|
112
|
-
errorMsg = `Video encoding failed.
|
|
111
|
+
errorMsg = `Video encoding failed. Check file format and try different codec`;
|
|
112
|
+
} else {
|
|
113
|
+
errorMsg = `Encoding error: ${err.message.substring(0, 80)}`;
|
|
113
114
|
}
|
|
114
115
|
|
|
115
116
|
resolve({
|