Announcement

Collapse
No announcement yet.

Why does an image have a larger file size after cropping

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [SOLVED] Why does an image have a larger file size after cropping

    I cropped goat-1.jpeg (51.9 KiB, 740wx960h, 0.7 MP) using Gwenview version 19.12.3. The resulting file, goat-2.jpeg (602wx680h, 0.4 MP), has a file size of 188.0 KiB.

    Why does the file size increase?

    goat-1.jpeg

    Click image for larger version  Name:	goat-1.jpeg Views:	15 Size:	44.0 KB ID:	658309

    goat-2.jpeg

    Click image for larger version  Name:	goat-2.jpeg Views:	12 Size:	186.2 KB ID:	658310
    Last edited by chimak111; Nov 18, 2021, 09:16 PM.
    Kubuntu 20.04

    #2
    (I know little about this stuff; all I know is to fire up imagemagick and punish myself with the docs till I give up, or occasionally achieve something.)

    imagemagick identify -verbose tells me the first jpg has "Quality: 75", but the second has "100". In gwenview, after cropping, the save as dialogue lets you set the "quality", defaulting to 100%. If I set this to 75%, the file size is 29.4 kiB. I suspect that there's something fishy here, maybe gwenview should default the jpeg quality to the original.
    Regards, John Little

    Comment


      #3
      Originally posted by jlittle View Post
      (I know little about this stuff; all I know is to fire up imagemagick and punish myself with the docs till I give up, or occasionally achieve something.)

      imagemagick identify -verbose tells me the first jpg has "Quality: 75", but the second has "100". In gwenview, after cropping, the save as dialogue lets you set the "quality", defaulting to 100%. If I set this to 75%, the file size is 29.4 kiB. I suspect that there's something fishy here, maybe gwenview should default the jpeg quality to the original.
      Thanks for looking into this! I too don't know the technicalities of image quality Plus, I mostly have my images as .png and Gwenview doesn't have the quality option for png files.

      I didn't pay attention to the save-as GUI other than to ensure the file was named differently but with the same extension. Next time, I'll be more careful with jpegs!

      Kubuntu 20.04

      Comment


        #4
        First: I know a little bit of these things, but I'm no expert too. To be an expert you have to spend all your time in it, because this is really very complicated stuff. But I think I know the 'big lines'.

        If you open your images next to each other in Gwenview and blow them up to 1600% (or in any other graphic viewer), you see the separate pixels the images are made off (every square block is a pixel). Because human eyes are easily fooled, we normally don't see these separate pixels.

        In your second image you can see there are more subtle colours: if going smoothly from black to white in your first image would take a white pixel, 50 grades of grey, and ending with black, in your second image there are used 100 shades of grey. For the human eye the second image looks more natural. (That's to say: most people don't notice the difference. Only with round lines like a thin black circle you can easily notice it, especially on high definition screens).

        To make your image as small as possible, jpg uses algorithms. If there's a block of 1000 red pixels changing slowly to a block of 1000 orange pixels, it uses some kind of formula instead of storing every pixel separate. So the filesize of your images becomes (much) smaller. Your first image is 592 pixel wide and 768 pixel high. That's in total 454.656 bytes, or 454,656 KiB. Times three, because for every pixel it has to store the amount of red, green and blue. Makes around 1364 KiB. (The mix of red, green and blue makes every colour you see.)

        If it really should store these information for every pixel, your first image would actually have a filesize of 1364 KiB. By using algorithms your first image is only 44 KiB instead of 1364 KiB. A lot of difference for downloading.

        Every time you make a change in a jpg-image and save it, it makes a completely new calculation how to store it. That's the reason a jpg-file (and also some other formats) are every time you change and save it, loosing a tiny little bit of their quality. You can hardly see it, but after changing and saving a jpg 50 times or so, you will surely see it: plain ugly. That's why jpg is called a 'lossy' format.

        There are formats that don't loose quality, but their filesize is most of the time (much) bigger.

        I don't know how Gwenview works when you save a changed jpg. (I didn't even know you can crop in Gwenview.) But one way or the other Gwenview probably 'improved' the quality: it added pixels, so your image looks 'nicer'. Between apostrophes, because there's no program on earth that can really improve an image. It only looks that way, because human eyes are easily fooled.
        What Gwenview does is 'guessing': if that images goes over a length from 100 pixels from black over grey to white, and there are 30 shades of grey, I'll make it 98 shades of grey by putting shades of grey in between. And extra colours mean a bigger filesize, because the algorithms can't compress them as much.

        If you have highly specialized programs like Gimp or Photoshop and enlarge an image, the result can be pretty good (for the human eye, an eagle would probably start crying). It's still 'guessing' what pixels to add. Most other programs will deliver much poorer results, because they are not specially made for this kind of work.

        So that's the reason your second image has a much bigger filesize.

        Tip: if you want to change and save a jpeg more than 3-4 times, convert it first to another format like BMP. BMP has a much bigger filesize, but is 'lossless': you can edit and save it without loosing quality. You make your changes in BMP, and than convert the final result back to jpg. Then you'll only loose no quality at all. BMP and sort alike formats are too big to use on internet. Downloading would take ages.

        These kind of images are called raster or bitmap, because they store every pixel separately (literally every pixel, or by using an algorithm). You've a completely different kind of image where no pixels at all are stored: vector formats, like SVG. They use mathematical formulas, like draw a black rectangle from the point top left ... pixel wide and ... pixel high.

        If you enlarge a bitmap-format, sooner or later you'll start to see the separate pixels. On high definition screens that can happen rather soon, especially with bad quality images. A vector image can be endlessly enlarged without loosing any quality, because you only change the mathematical formula: change '100 pixel high' in '200 pixel high'. The browser (or any other program) simply makes a completely new image, based on the new formulas.
        But vector images are only usable for things like logos and flags with few colours and big areas of (almost) one colour. If you have a normal photo, the amount of mathematical formulas to draw that would be so big, you'll end up with a filesize of gigabytes.

        Well, maybe you were not that interested at all, but it's always fun to write a little bit.
        Last edited by Goeroeboeroe; Nov 18, 2021, 08:50 AM. Reason: Made a mistake in the tip: wrote you loose one time quality, but you don't use any at all. Corrected that

        Comment


          #5
          Originally posted by Goeroeboeroe View Post
          ...
          Well, maybe you were not that interested at all, but it's always fun to write a little bit.
          It was a joy to read! Thank you!

          (BTW, Gwenview can save as BMP: a 318 KiB jpeg becomes a 1.3 MiB bmp and now I know why)
          Kubuntu 20.04

          Comment

          Working...
          X