linuxubuntujpegoptim

jpegoptim --dest option format


I am trying to compress a couple of pictures with jpegoptim. There is an option in the man pages for specifying the destination of the newly compressed jpg file (so it does not overwrite the existing file). I tried using the option but I keep getting

jpegoptim: invalid argument for option -d, --dest

The folder hierarchy is: JPGs
-coverjem228.jpg (picture file)
-compressed (dir)

I am trying to place them in the compressed directory after compression. I have tried the following command variations:

jpegoptim -d /compressed --size=60k coverjem228.jpg 
jpegoptim --dest=/compressed --size=60k coverjem228.jpg 
jpegoptim -d ./compressed --size=60k coverjem228.jpg 
jpegoptim --dest=./compressed --size=60k coverjem228.jpg 

However the error persists. Interestingly the only commands that work are

jpegoptim -d . --size=60k coverjem228.jpg 
jpegoptim --dest=. --size=60k coverjem228.jpg 

and

jpegoptim -d .. --size=60k coverjem228.jpg 
jpegoptim --dest=.. --size=60k coverjem228.jpg 

Am I writing the command wrong?


Solution

  • In the man page, it says

    -d<path>, --dest=<path>
    

    This means, if your destination folder was named "compressed", and in the same location as your images, then, you can specify the destination in one of the following ways.

    jpegoptim --dest=compressed --size=60k coverjem228.jpg
    jpegoptim -dcompressed --size=60k coverjem228.jpg 
    

    The following code works, because . and .. are valid folders(current and parent folders)

    jpegoptim --dest=.. --size=60k coverjem228.jpg 
    

    The following code works for the same reason. But, it works with and without a space between -d and the . (dot) . but raises warning that image already exists.

    jpegoptim -d . --size=60k coverjem228.jpg