Yuriy-Svetlov / compress-images

Minify size your images. Image compression with extension: jpg/jpeg, svg, png, gif. NodeJs
https://www.npmjs.com/package/compress-images
MIT License
593 stars 76 forks source link

images are not saved to exact paths #49

Open Eriickson opened 3 years ago

Eriickson commented 3 years ago

Hello, your package partly works for me, but it does not save the images already compressed in the folder that I specify

If you notice, I specify the directory where the original image is located as well as the directory where the compressed image will be stored

image

and the output message confirms to me that it was successfully saved to the directory that I specified image

but when I go to check to confirm, it was not saved in said directory, but rather it is saved where the original one is and to the name it adds a suffix "-fs8" image I hope you can help me

Jovans025 commented 3 years ago

I also encountered this one, some image works well some goes to this one with adding: fs-8 suffix. In my case the server goes down Screen Shot 2020-10-23 at 1 16 02 PM

I manage to fix by going to node_modules/compress-images/index.js:1477 and adding a try catch. Screen Shot 2020-10-23 at 1 17 28 PM Unfortunately it will only work on local since package will be reinstalled upon deployment. For now I have grabbed the package and put it my code utils.

Yuriy-Svetlov commented 3 years ago

@Eriickson Hello!

Show please your configuration of compress images. Do you may give me your image?

Yuriy-Svetlov commented 3 years ago

@Jovans025 Hello!

Show please your configuration of compress images. Do you may give me your image?

mathieutu commented 2 years ago

For me it actually happens for all the png. (pngquant, quality 20-50)

Yuriy-Svetlov commented 2 years ago

@mathieutu

For me it actually happens for all the png. (pngquant, quality 20-50)

Can you give me your image of which this is happening?

mathieutu commented 2 years ago

As I said, for me it's the same for all png files.

I give you one of mine:

01

It starts by creating a 01-fs8.png.tmp then save the result in 01-fs8.png

(I've even tested by downloading the image from the github preview, to be sure you'll be able to reproduce)

Thanks.

Yuriy-Svetlov commented 2 years ago

@mathieutu

I renamed the downloaded image to 01-fs8.png

I was unable to reproduce the problem

Yuriy-Svetlov commented 2 years ago

@mathieutu

my script:

compress-images ver 1.9.7

    var compress_images = require('compress-images');

    const INPUT_path_to_your_images = 'src/img/**/*.{jpg,JPG,jpeg,JPEG,png,svg,gif}';
    const OUTPUT_path = 'build/img/';

    compress_images(INPUT_path_to_your_images, OUTPUT_path, {compress_force: false, statistic: true, autoupdate: true}, false,
                                                {jpg: {engine: 'mozjpeg', command: ['-quality', '60']}},
                                                {png: {engine: 'pngquant', command: ['--quality=20-50', '-o']}},
                                                {svg: {engine: 'svgo', command: '--multipass'}},
                                                {gif: {engine: 'gifsicle', command: ['--colors', '64', '--use-col=web']}}, function(){
    });
Yuriy-Svetlov commented 2 years ago

@mathieutu Maybe you need to change the extension from 01-fs8.png.tmp to 01-fs8.png?

mathieutu commented 2 years ago

This is not the problem. The problem is precisely that the image is not saved in the output folder specified, but in the source folder, with a -fs8.png extension.

I let you see the issue description for screenshots. I haven't anything more.

Yuriy-Svetlov commented 2 years ago

@mathieutu

This does not happen for me, I checked it again. I also checked the files in the folders and their size after compression.

'Starting compress images'

File from: src/img/1/01.png File to: build/img/1/01.png Compression algorithm: [pngquant] Original size: [3.76MB] | Compressed size: [509.03KB] | Compression rate: [86.78%]

'Compress images completed' 'Console will be close after [20] seconds...'

Here's what I was able to find

https://github.com/kornelski/pngquant#--ext-newpng https://stackoverflow.com/questions/43027319/php-simple-script-for-image-compression-with-pngquant https://www.google.com/search?q=fs8+pngquant&ei=OECqYdjAJObErgTs9KigAw&oq=pngquant+fs&gs_lcp=Cgdnd3Mtd2l6EAEYADIGCAAQFhAeOgcIABBHELADOgcIABCwAxBDOgUIABCABDoECAAQQ0oECEEYAFCyBFjRJWCVMWgBcAJ4AIABd4gB0QKSAQMwLjOYAQCgAQHIAQrAAQE&sclient=gws-wiz

probityrules commented 1 year ago

I also ran into this same issue running on Win 10, Node v14. I was able to workaround it by forcing the rename to not use -fs8 by using the following settings for PNG compression:

{
    png: {
        engine: 'pngquant',
        command: ['--quality=50-80', '--force', '-o']
    }
}