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

images are not saved to exact paths #49

Open
Eriickson opened this issue Oct 4, 2020 · 12 comments
Open

images are not saved to exact paths #49

Eriickson opened this issue Oct 4, 2020 · 12 comments

Comments

@Eriickson
Copy link

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
Copy link

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
Copy link
Owner

@Eriickson
Hello!

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

@Yuriy-Svetlov
Copy link
Owner

@Jovans025
Hello!

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

@mathieutu
Copy link

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

@Yuriy-Svetlov
Copy link
Owner

@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
Copy link

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
Copy link
Owner

@mathieutu

I renamed the downloaded image to 01-fs8.png

I was unable to reproduce the problem

@Yuriy-Svetlov
Copy link
Owner

Yuriy-Svetlov commented Dec 3, 2021

@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
Copy link
Owner

Yuriy-Svetlov commented Dec 3, 2021

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

@mathieutu
Copy link

mathieutu commented Dec 3, 2021

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
Copy link
Owner

@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
Copy link

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

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

5 participants