Search code examples
linuxbashshellimage-compression

Shell commando not working for compression photo's by TinyPNG


Hello guys I don't real know much about shells. I need to compress some PNG files and I found a bash shell script on the web. The bash shell normally works with the API of tinyPNG

When I run the shell I get this error:

bash: tinypng.sh: command not found...

I tried to run it by this method:

tinypng.sh  -d [DIRECTORY]/

I have also tried to do this:

bash tinypng.sh  -d [DIRECTORY]/

When I run that I just this info :

NAME tinypng - Shrink PNGs using tinypng.com service.

SYNOPSIS tinypng [-dkph] -f FILE

DESCRIPTION Shrink PNGs using tinypng.com service.

On first execution, or if /DIRECTORY/DIRECTORY/.tinypng.apikey is not present, tinypng will ask for an API key.

Obtain your API key from https://tinypng.com/developers, copy and paste it when prompted.

OPTIONS

-f,--file FILE              Select a FILE to be shrinked.
    -d,--download DIRECTORY     Download all shrinked PNGs to DIRECTORY.
    -k,--key API_KEY            Use API_KEY, instead of the one stored in /DIRECTORY/DIRECTORY/.tinypng.apikey.         -p,--print                  When -d is being used, the URLs of the shrinked PNGs are not being printed to stdout.                                     Use this option to force printing even when using -d.
                                Otherwise, this option is set implicitly.
    -- FILES                    Ignore any options to come.
                                Everything after this option is considered a file.
    -h,--help                   Show this message and exit successfully.
         EXAMPLES
   Shrink foo.png, bar.png, baz.png and print the result URLs to stdout.
     $ tinypng -f foo.png -f bar.png -f baz.png
         or
     $ tinypng -- foo.png bar.png baz.png
     Shrink foo.png, bar.png, baz.png and download the result PNGs to tiny_pngs/ directory
    $ tinypng -d tiny_pngs/ -- foo.png bar.png baz.png

Written by Rany Albeg Wein - rany.albeg@gmail.com


Solution

  • tinypng --help shows your solution:

    tinypng -d tiny_pngs/ -- foo.jpg bar.png baz.png

    which will shrink foo.jpg, bar.png, baz.png and download the shrinked files to tiny_pngs/ directory.