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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "image-video-optimizer",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "CLI tool to optimize and compress images and videos with configurable settings",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -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
- image = image[outputFormat]({ quality: 80 });
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
@@ -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 = `Video codec error. Check available codecs with: ffmpeg -encoders | grep lib`;
107
- } else if (err.message.includes('is not available')) {
108
- errorMsg = `Codec not available. Verify FFmpeg installation: ffmpeg -version`;
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 (macOS) or apt-get install ffmpeg (Linux)`;
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. Try a different codec in config: video_encode=h265 or video_encode=vp8`;
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({