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

Recursive directories via command line #4

Closed
jakemauer opened this issue Nov 15, 2012 · 11 comments
Closed

Recursive directories via command line #4

jakemauer opened this issue Nov 15, 2012 · 11 comments

Comments

@jakemauer
Copy link

Hey Ivan,

First thank you so much for your work on this.

Is there a way to target multiple directories or recurse through directories and compress all images within?

@toy
Copy link
Owner

toy commented Nov 15, 2012

Hi Jake,

Thank you, I am glad that my work it helpful )

For now there is no option to tell image_optim to find images in directory. Though you can pass all files (using globs or find) and non images will be ignored (directories will be also ignored, but you will get a warning).

I remember that I was thinking of adding recursive search but don't remember why I did not implement it. It should be simple to add, I'll try to do this soon.

@jakemauer
Copy link
Author

Thanks Ivan,

I'm using image_optim find **/*.{png,jpg,jpeg,gif} for now and it seems to work. Any issues with this?

@toy
Copy link
Owner

toy commented Nov 15, 2012

Only now I've noticed that command seems wrong as image_optim find **/*.{png,jpg,jpeg,gif} will try to optimize file named find and whatever it can find by glob.

I've already added code for recursive searching for files, though I should add selecting only images and change how non images are handled inside, than there will be next release.

@toy
Copy link
Owner

toy commented Nov 15, 2012

0.6.0 is out with recursive search for images.

@toy toy closed this as completed Nov 15, 2012
@el3ment
Copy link

el3ment commented Dec 26, 2013

How do you utilize the -r recursive option?

@toy
Copy link
Owner

toy commented Dec 26, 2013

@el3ment For example image_optim -r dir_a dir_b dir_c. It will scan those three directories for images that it can optimize and will run optimization process. With -r you can mix directory paths and file paths in one call.

@el3ment
Copy link

el3ment commented Dec 26, 2013

Thanks for the timely response! Just as a small caveat - in directories with lots of folders and files, image_optim -r */.{jpg,png} or image_optim -r ** will result in an "Argument List Too Long" shell error - do you know of a convenient way of avoiding this error?

@toy
Copy link
Owner

toy commented Dec 26, 2013

@el3ment In your case simple image_optim -r . should work as expected. In other cases you can use find with -exec like find . \( -name '*.jpg' -or -name '*.png' \) -exec image_optim {} +.

@soufiane-fadil
Copy link

Hi all ,

Please i have you probleme when typing : image_optim *.{jpg,png,gif,svg} on my shell

i got this :

WARN: advpng 1.15 at /usr/bin/advpng (< 1.17) does not use zopfli
WARN: gifsicle 1.60 at /usr/bin/gifsicle (< 1.85) does not support removing extension blocks
Bin resolving errors:
pngout worker: pngout not found; please provide proper binary or disable this worker (--no-pngout argument or :pngout => false through options)
pngquant worker: didn't get version of pngquant ? at /usr/local/bin/pngquant; please provide proper binary or disable this worker (--no-pngquant argument or :pngquant => false through options)

Can you help me please ?

Thank you

@toy
Copy link
Owner

toy commented Jan 25, 2015

@bloodymind Simplest way to get up-to-date versions of nearly all binaries is by installing image_optim_pack gem, the only requirement is operation system — linux or osx.
If you are using it for a project using bundler, you may want to add it to Gemfile.
Also pngout is not yet packed due to license, so you need to download it manually and put it somewhere on path.

Otherwise please check binaries installation section in readme.

@soufiane-fadil
Copy link

Hi @toy ,

That's working now 👍

Thank you.

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

4 participants