Skip site navigation (1)Skip section navigation (2)

  
 
  

home | help
JPEGOPTIM(1)		     General Commands Manual		    JPEGOPTIM(1)

NAME
     jpegoptim - utility to optimize/compress JPEG/JFIF files.

SYNOPSIS
     jpegoptim [ options ] [ filenames ]

DESCRIPTION
     jpegoptim	is  used to optimize/compress jpeg files. Program supports loss-
     less optimization, which is based on optimizing the Huffman tables. And  so
     called  "lossy" optimization where in addition to optimizing Huffman tables
     user can specify upperlimit for image quality.

     NOTE! By default jpegoptim modifies the input  files  (if	they  are  opti-
     mized),  to  preserve original files use option -d to specify alternate di-
     rectory for saving the optimized files to.

     Only normal files are optimized  (symbolic  links	and  special  files  are
     skipped).	 Also, any other hard links to the file being optimized (as cre-
     ated using link(2)) are unaffected.

OPTIONS
     Options may be either the traditional POSIX one letter options, or the  GNU
     style  long  options.  POSIX style options start with a single ``-'', while
     GNU long options start with ``--''.

     Options offered by jpegoptim are the following:

     -d<path>, --dest=<path>
	   Sets alternative destination directory where to save optimized  files
	   (default  is  to overwrite the originals). Please note that unchanged
	   files won't be added to the destination directory. This means if  the
	   source  file can't be compressed, no file will be created in the des-
	   tination path.

     -f, --force
	   Force optimization, even if the result would be larger than the orig-
	   inal file.

     -h, --help
	   Displays short usage information and exits.

     -m<quality>, --max=<quality>
	   Sets the maximum image quality factor (disables lossless optimization
	   mode, which is by default enabled). This option will  reduce  quality
	   of  those  source files that were saved using higher quality setting.
	   While files that already have lower	quality  setting  will	be  com-
	   pressed using the lossless optimization method.

	   Valid values for quality parameter are: 0 - 100

     -n, --noaction
	   Don't really optimize files, just print results.

     -S<size>, --size=<size>
	   Try	to  optimize  file to given size (disables lossless optimization
	   mode). Target size is specified either in kilobytes (1  -  n)  or  as
	   percentage (1% - 99%) of the original file size.

     -T<threshold>, --threshold=<threshold>
	   Keep  the  file  unchanged  if the compression gain is lower than the
	   threshold (%).

	   Valid values for threshold are: 0 - 100

     -w<max>, --workers=<max>
	   Set the maximum number of parallel processes to launch.  (Default  is
	   1)

     -b, --csv
	   Print progress info in CSV format.

     -o, --overwrite
	   Overwrite target file even if it exists (when using -d option).

     -p, --preserve
	   Preserve file modification times.

     -P, --preserve-perms
	   Preserve  file  permissions (owner/group) by overwriting the original
	   file. This is slightly less safe than the default mode  of  operation
	   (where  new	file  is  first saved as temporary file and then renamed
	   over the original file).  In this mode a backup of the original  file
	   is made with .jpegoptim.bak extension, and this file is removed after
	   the	original  file has been successfully replaced.	NOTE! if running
	   jpegoptim as root there is generally no need to use this  option,  as
	   jpegoptim  is  able	to preserve file permissions when run by root in
	   default mode.

     -q, --quiet
	   Quiet mode.

     -r, --retry
	   Recursively re-try compression until output file size  does	not  get
	   smaller  anymore.   This  can result a few bytes smaller output file,
	   but with the expense of lot more computing time used.

	   NOTE! This option is on only effective when used in compbination with
	   -m (--max) or -S (--size) option.

     -t, --totals
	   Print totals after processing all files.

     -v, --verbose
	   Enables verbose mode (positively chatty).

     --auto-mode
	   Select progressive vs non-progressive mode based on	which  one  pro-
	   duces  smaller  output file. By default mode (progressive vs non-pro-
	   gressive) is preserved.

     --all-normal
	   Force all output files to be non-progressive. Can be used to  convert
	   all	input  files to non-progressive JPEGs when used with --force op-
	   tion.

     --all-progressive
	   Force all output files to be progressive. Can be used to convert  all
	   normal  (non-progressive)  JPEGs input files to progressive when used
	   with --force option.

     --all-arith
	   Force all output files to use Arithmetic Coding.  This option is  ex-
	   perimental  and  only available if jpegoptim was compiled with Arith-
	   metic Coding support enabled.

     --all-huffman
	   Force all output files to use (traditional) Huffman coding.	This op-
	   tion is experimental and only available  if	jpegoptim  was	compiled
	   with Arithmetic Coding support enabled.

     --nofix
	   Skip processing of any input files that have any errors/warnings dur-
	   ing decompression.  By default jpegoptim will attempt to optimize any
	   file  that  it is able to decompress, even if decompression generates
	   warnings. This will 'fix' some (corrupt) JPEG  images  automatically.
	   If  this  behaviour	is  not desired, this option can be used to make
	   jpegoptim to skip any input files that contain any errors.

     --save-extra
	   Save extraneous data after end of the JPEG image in	the  input  file
	   (default  is  to  discard  any extraneous data after the end of image
	   that may be present).  This may be useful if JPEG image contains non-
	   standard extensions that are not  part  of  the  JPEG  image  format.
	   NOTE!  This	option	does  not  work if input JPEG image is read from
	   standard input (stdin).

     --stdout
	   Send output image to standard output. Note,	if  optimization  didn't
	   create  smaller file than the input file, then no output original im-
	   age is passed through unmodified (except any extra  data  after  JPEG
	   image will be discarded).

     --stdin
	   Read input image from standard input and send output to standard out-
	   put (--stdout is assumed when this option is used).	When this option
	   is used then only one image is read from standard input.  Any (other)
	   input  files  specified  on command-line are ignored.  Note, if input
	   file '-' is seen on command line then standard input is also assumed.

     --files-stdin
	   Read names of files to process from standard input. One filename  per
	   line.

     --files-from=<filename>
	   Read names of files to process from a file. One filename per line.

METADATA OPTIONS
     By  default  jpegoptim will keep common metadata (JPEG markers) and discard
     any other (unknown ones).

     Following markers are kept by default:
      - EXIF
      - IPTC
      - ICC
      - XMP
      - COM (JPEG Comment markers)

     JFIF marker will be regenerated (by libjpeg) during the process (this  can-
     not  be  changed).  However, Adobe marker is also generated (or omitted) by
     libjpeg based on the image colorspace, etc.  This behavior depends on  lib-
     jpeg library version being used. To make sure Adobe marker is preserved op-
     tion --keep-adobe can be used.

     To remove additional markers one or more the --strip-* options can be used.

     For example:      --strip-icc --strip-xmp --strip-com

     Alternatively it is possible to specify --strip-all and then one or more of
     the --keep-* options to explicitly list which markers to keep

     For example:      --strip-all --keep-exif --keep-iptc

     Options for controlling metadata (markers) in output files:

     -s, --strip-all
	   Strip  all markers from output file. (NOTE! by default only Comment &
	   Exif/IPTC/PhotoShop/ICC/XMP markers are kept, everything else is dis-
	   carded).  Output JPEG still likely will contains one or  two  markers
	   (JFIF  and Adobe APP14) depending on colorspace used in the image, as
	   these markers are generated by the libjpeg encoder automatically.

     --strip-none, --keep-all
	   Preserve "all" markers in the image. This will leave all markers  un-
	   touched in the image, except JFIF (APP0) and Adobe (APP14) markers as
	   those get regenerated by the libjpeg library.

	   NOTE!  If  this  option  is	specified  then  any  other --strip-* or
	   --keep-* options are ignored.

     --strip-com
	   Strip Comment (COM) markers from output file.

     --strip-exif
	   Strip EXIF markers from output file.

     --strip-iptc
	   Strip IPTC / Adobe Photoshop (APP13) markers from output file.

     --strip-icc
	   Strip ICC profiles from output file.

     --strip-xmp
	   Strip XMP profiles from output file.

     --strip-jfif
	   Strip JFIF markers from output file.

     --strip-jfxx
	   Strip JFXX (JFIF Extensions) markers from output file.

     --strip-adobe
	   Strip Adobe markers from output file.

     --keep-com
	   Do not strip any Comment (COM) markers from output file.

     --keep-exif
	   Do not strip any EXIF markers from output file.

     --keep-iptc
	   Do not strip any IPTC / Adobe Photoshop (APP13) markers  from  output
	   file.

     --keep-icc
	   Do not strip any ICC profiles from output file.

     --keep-xmp
	   Do not strip any XMP profiles from output file.

     --keep-jfif
	   Do not strip any JFIF markers from output file.

     --keep-jfxx
	   Do not strip any JFXX (JFIF Extensions) markers from output file.

     --keep-adobe
	   Do not strip Adobe markers from output file.

BUGS
     When  using  --size  option,  resulting  file is not always exactly the re-
     quested size. Workaround is to re-run jpegoptim  on  the  same  file  again
     which often will result file closer to target size.

SEE ALSO
     jpeginfo(1)

AUTHOR
     Timo Kokkonen <tjko@iki.fi>

COPYING
     Copyright (C) 1996-2025  Timo Kokkonen

     This program is free software; you can redistribute it and/or modify it un-
     der  the  terms  of the GNU General Public License as published by the Free
     Software Foundation; either version 2 of the License, or (at  your  option)
     any later version.

     This program is distributed in the hope that it will be useful, but WITHOUT
     ANY  WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT-
     NESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
     details.

     You should have received a copy of the GNU  General  Public  License  along
     with  this program; if not, write to the Free Software Foundation, Inc., 51
     Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

4th Berkeley Distribution	   28 Jan 2025			    JPEGOPTIM(1)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=jpegoptim&sektion=1&manpath=FreeBSD+Ports+15.1.quarterly>

home | help