Resizing images with jpegoptim

Discussion in 'GNU/Linux' started by melbo, Mar 7, 2015.


  1. melbo

    melbo Hunter Gatherer Administrator Founding Member

    DESCRIPTION
    jpegoptim is used to optimize/compress jpeg files. Program supports
    lossless 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.

    jpegoptim syntax: jpegoptim [ options ] [ filenames ]
    (options at the bottom of this post)

    Lossless:
    jpegoptim file.jpg

    Lossy:
    jpegoptim --max=XX file.jpg

    Results of max=85
    3888x2592 24bit N Exif [OK] 3435621 --> 1024056 bytes (70.19%), optimized.

    Results of max=65
    3888x2592 24bit N Exif [OK] 3435621 --> 542022 bytes (84.22%), optimized.


    Original 3.4MB
    IMG_3977.JPG


    Optimized (jpegoptim --max=85 file.jpg) 1.0MB final filesize
    IMG_3977opt.JPG


    Optimized (jpegoptim --max=65 file.jpg) 542kB final filesize
    IMG_3977opt65.JPG



    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 destination path.

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

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

    -m<quality>, --max=<quality>
    Sets the maximum image quality factor (disables lossless opti-
    mization 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 compressed 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 opti-
    mizaiont mode). Target size is specified either in kilobytes (1 -
    n) or as percentage (1% - 99%) of the original file size.

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

    Valid values for treshold are: 0 - 100

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

    -p, --preserve
    Preserve file modification times.

    -q, --quiet
    Quiet mode.

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

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


    --all-normal
    Force all output files to be non-progressive. Can be used to con-
    vert all input files to progressive JPEGs when used with --force
    option.

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


    --strip-all
    Strip all (Comment & Exif) markers from output file. (NOTE! by
    default only Comment & Exif markers are kept, everything else is
    discarded)

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

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

    --strip-iptc
    Strip IPTC markers from output file.

    --strip-icc
    Strip ICC profiles from output file.
     
    stg58 likes this.
  2. melbo

    melbo Hunter Gatherer Administrator Founding Member

    So let's see how lossy is too lossy. Of course, these are now displaying in the forum as resized for web view although the degradation will probably become apparent once you 'click to zoom'. If we can jpegoptim all of our images from (average) 4MB down to 0.3MB or less without anyone noticing, that would be cool @ghrit

    --max=55
    3888x2592 24bit N Exif [OK] 3435621 --> 449152 bytes (86.93%), optimized.
    449kB
    IMG_3977opt55.JPG


    --max=45
    3888x2592 24bit N Exif [OK] 3435621 --> 394124 bytes (88.53%), optimized.
    394kB
    IMG_3977opt45.JPG



    --max=35
    3888x2592 24bit N Exif [OK] 3435621 --> 337511 bytes (90.18%), optimized.
    337kB
    IMG_3977opt35.JPG


    jpegoptim --max=25 '/home/######/Desktop/IMG_3977.JPG'
    /home/#####/Desktop/IMG_3977.JPG 3888x2592 24bit N Exif [OK] 3435621 --> 272170 bytes (92.08%), optimized.
    272kB
    IMG_3977opt25.JPG


    jpegoptim --max=15 '/home/####/Desktop/IMG_3977opt15.JPG'
    /home/#####/Desktop/IMG_3977opt15.JPG 3888x2592 24bit N Exif [OK] 3435621 --> 196149 bytes (94.29%), optimized.
    196kB
    IMG_3977opt15.JPG



    jpegoptim --max=5 '/home/####/Desktop/IMG_3977.JPG'
    /home/#####/Desktop/IMG_3977.JPG 3888x2592 24bit N Exif [OK] 3435621 --> 111572 bytes (96.75%), optimized.
    111kB
    IMG_3977.JPG

    Starting to pixelate to unacceptable at <25 to my eye. Last test was at 5%... Let's try max=1 for giggles

    jpegoptim --max=1 '/home/#####/Desktop/IMG_3977.JPG'
    /home/#####/Desktop/IMG_3977.JPG 3888x2592 24bit N Exif [OK] 3435621 --> 91511 bytes (97.34%), optimized.
    91kB
    IMG_3977opt1.JPG

    IMG_3977opt5.JPG
     
    Last edited: Jul 30, 2015
  3. Yard Dart

    Yard Dart Vigilant Monkey Moderator

    At 196 kb they start to turn...
     
  4. DarkLight

    DarkLight Live Long and Prosper - On Hiatus

    That was where these less than perfect eyes started to notice as well.
     
  5. ghrit

    ghrit Bad company Administrator Founding Member

    The idea is reduced downloading time for the larger images. That seems to be a beneficial result, going by how fast those test shots loaded, but it's only one message. The proof of the method will come in pic heavy threads. Playing the obvious card, I have to wonder how important it is for high res pix within the threads, and also I have to be sympathetic to the poor souls on dialup or other restricted speed connections.
     
  6. kellory

    kellory An unemployed Jester, is nobody's fool. Banned

    As long as the pic is not a detail issue, being shown. Many of those I will zoom in tight to see every detail. (How things work, is an interest of mine.) Casual pics, I have no problem losing a bit of clarity, but once gone, I don't think you can go backwards.
    Perhaps a choice could be given to posters as to which level of clarity is needed?:)
     
  7. melbo

    melbo Hunter Gatherer Administrator Founding Member

    Still looking into this but trying to make sure that any image processing is automatic and in the background so the user is unaffected.
     
    Yard Dart, ghrit and Ganado like this.
  8. melbo

    melbo Hunter Gatherer Administrator Founding Member

    @Yard Dart Do you think we'd be alright with the --max=55 image or could we go lower?
     
    Ganado and Yard Dart like this.
  9. Yard Dart

    Yard Dart Vigilant Monkey Moderator

    I think we could go lower if it benefits the site/cost/download speed. 45 or 35 possibly would still look good but would probably be the floor on what you would want to do.
     
    Ganado likes this.
  10. melbo

    melbo Hunter Gatherer Administrator Founding Member

    We ripped through 40K+ images last night at 65 :)
     
    Ganado and Yard Dart like this.
  11. melbo

    melbo Hunter Gatherer Administrator Founding Member

    All new images posted are auto-resized when submitted
     
    Dont, BTPost, Ganado and 2 others like this.
survivalmonkey SSL seal        survivalmonkey.com warrant canary
17282WuJHksJ9798f34razfKbPATqTq9E7