Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console shows "Images Optimized", but there are no images in output folder. #23

Open
nordskill opened this issue Jul 24, 2019 · 10 comments

Comments

@nordskill
Copy link

nordskill commented Jul 24, 2019

Hi,
in "images/" I have several .jpg images. I use the code from example and run it in node.js environment. After running the script I'm getting 'Images optimized' in console log, but nothing happens. The whole process takes less than 1 sec. Are those images converted, but not saved? Or they're just skipped?

@BoniWPy
Copy link

BoniWPy commented Aug 8, 2019

yes thats true, me too.

@mhstoller
Copy link

Yes, the problem does not seem to be with the plugin itself, however. It looks like a possible upstream issue: imagemin/imagemin#327

@mhstoller
Copy link

mhstoller commented Aug 18, 2019

In my case it seems that the plugin was unable to support the file type. I'm not sure why no errors were thrown, but I've solved it using different methods and determining the mime type ahead of time....

Ultimately the plugin is using this library: https://www.npmjs.com/package/cwebp-bin

So it seems if the image conversion fails in that library then the output from imagemin is the original file.

@cksho
Copy link

cksho commented Aug 24, 2019

Also example of usage on imagemin-webp is little bit misleading, dunno if imagemin has a new API but below should work:

const imagemin = require('imagemin');
const imageminWebp = require('imagemin-webp');

(async () => {
  const files = await imagemin(['./images/*.{jpg}'], {
    destination: 'build/images',
    plugins: [imageminWebp()],
  });

  console.log(files);
})();

@oproulx
Copy link

oproulx commented Oct 27, 2019

Had the same problem and @cksho example code solved it.

@4k1k0
Copy link

4k1k0 commented Jan 2, 2020

Hello, I already used the destination key in the options object, but that only makes a copy of the original jpg file I try to convert to webp. It doesn't create a new image with webp extension.

const imagemin = require('imagemin');
const imageminWebp = require('imagemin-webp');

(async () => {
  const img = await imagemin(['images/*.jpg'], {
    destination: 'build/images',
    use: [
      imageminWebp({quality: 100})
    ]
  });

  console.log('Images optimized');
  console.log(img)
})();

@AskingQuestions
Copy link

For those who are having this problem, the use keyword is no longer working. plugins is the correct option.

const imagemin = require('imagemin');
const imageminWebp = require('imagemin-webp');

(async () => {
  const img = await imagemin(['images/*.jpg'], {
    destination: 'build/images',
    plugins: [
      imageminWebp({quality: 100})
    ]
  });

  console.log('Images optimized');
  console.log(img)
})();

@LambdaZed
Copy link

For Windows users.
You need to replace slahes to unix format

const path = require('path');
const imagemin = require('imagemin');
const imageminWebp = require('imagemin-webp');

(async () => {
  const img = await imagemin([path.resolve(__dirname, 'img/*.{jpg,png}').replace(/\\/g, '/')], {
    destination: path.resolve(__dirname, 'dist/webp').replace(/\\/g, '/'),
    plugins: [imageminWebp({ quality: 70 })],
  });

  console.log('Images optimized');
  console.log(img);
})();

@qwekelly
Copy link

it can’t done, and the problem still as usuall @LambdaZed

@PyGod
Copy link

PyGod commented Apr 16, 2024

Hi! Did someone find a solution? It is still a problem...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants