compress-images icon indicating copy to clipboard operation
compress-images copied to clipboard

images are not saved to exact paths

Open Eriickson opened this issue 3 years ago • 12 comments

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

Eriickson avatar Oct 04 '20 00:10 Eriickson

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.

Jovans025 avatar Oct 23 '20 05:10 Jovans025

@Eriickson Hello!

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

Yuriy-Svetlov avatar Nov 12 '20 12:11 Yuriy-Svetlov

@Jovans025 Hello!

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

Yuriy-Svetlov avatar Nov 12 '20 18:11 Yuriy-Svetlov

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

mathieutu avatar Nov 23 '21 11:11 mathieutu

@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?

Yuriy-Svetlov avatar Nov 23 '21 15:11 Yuriy-Svetlov

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.

mathieutu avatar Dec 02 '21 09:12 mathieutu

@mathieutu

I renamed the downloaded image to 01-fs8.png

I was unable to reproduce the problem

Yuriy-Svetlov avatar Dec 03 '21 10:12 Yuriy-Svetlov

@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 avatar Dec 03 '21 10:12 Yuriy-Svetlov

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

Yuriy-Svetlov avatar Dec 03 '21 10:12 Yuriy-Svetlov

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.

mathieutu avatar Dec 03 '21 10:12 mathieutu

@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

Yuriy-Svetlov avatar Dec 03 '21 16:12 Yuriy-Svetlov

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']
    }
}

probityrules avatar Oct 26 '22 16:10 probityrules