Increased file size after optimization JPG

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
konstantin.s
Posts: 2
Joined: 2018-08-31T04:57:14-07:00
Authentication code: 1152

Increased file size after optimization JPG

Post by konstantin.s »

Hello everyone.

I faced the following problem.
I have the increased file size for some JPG files after any manipulation with ImageMagick.

For example, my code for image optimization:
convert -sampling-factor 4:2:0 -strip -quality 55 -interlace JPEG -colorspace sRGB -define jpeg:fancy-upsampling=off source.jpg source-1.jpg

Source file: https://drive.google.com/file/d/1b_2axs ... sp=sharing
Size of the source file: 188 kb
Size after optimization: 233 kb

This happens and after cropping of the file.

For example, I received the file with identical file size via jpgtran tool.

So, I want to understand why this happens. Which parameter in the source file affected by this result?
Is it possible to reduce or save source file size after manipulation in ImageMagick?

Thanks.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Increased file size after optimization JPG

Post by snibgo »

Your source file says "You need permission".

IM reads and decompresses the image. Then it processes the image in-memory. Then it compresses and saves the image. The compression settings are probably different from those that originally saved the source. For JPEG, "-quality" adjusts the size versus fidelity trade-off.

"-define jpeg:extent=XXX" may be useful to you.
snibgo's IM pages: im.snibgo.com
konstantin.s
Posts: 2
Joined: 2018-08-31T04:57:14-07:00
Authentication code: 1152

Re: Increased file size after optimization JPG

Post by konstantin.s »

> Your source file says "You need permission".
Permissions were changed. You can see the file now.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Increased file size after optimization JPG

Post by fmw42 »

Using ImageMagick identify -verbose, your source file shows Filesize: 193378 B (193 KB) and Quality: 55

Using

Code: Select all

convert source.jpg -strip -colorspace sRGB -interlace JPEG -define jpeg:fancy-upsampling=off -sampling-factor 4:2:0 -quality 55 source-1.jpg
which shows, Filesize: 239460 B (239 KB) and Quality: 55

My guess is that your input file was generated with some other set of q tables and/or optimized.

ImageMagick uses libjpeg, which may use a different set of q tables and may not do as good a job optimizing. You may need to find some other jpeg optimizer tool.
Post Reply