3

I have a low quality background image that is about 85kb. If I open the file in Photoshop and then save it at 100% quality, the file size increases to 640kb. This doesn't make sense, the image is already compressed, the quality cannot be better than the source, so the 100% quality while saving should produce the file size as the opened file.

The problem is, I have this background and want to add a logo image over it, and then save it. But If I do so, I have to save this with 10% quality, and the logo looks horrible. If I save this to 100% quality, the file size is huge.

How can I achieve this?

4
  • This isn't really a webmaster issue I am afraid. Not sure where I would even suggest to find out about this sorry.
    – Toby
    Commented Nov 30, 2011 at 1:06
  • This belongs on the Graphics Design Stack Exchange Site, so I am sending it there. Also, what file format are you saving from and too and what settings are you using to save within that format? That can affect the file size greatly.
    – RandomBen
    Commented Nov 30, 2011 at 2:59
  • its simply goes weird with logo might be logo have some details, you can try optimization saving...
    – Jack
    Commented Nov 30, 2011 at 5:06
  • Sorry, i was saving in JPeg. Thanks for everybody help Commented Nov 30, 2011 at 13:31

5 Answers 5

9

Why low quality JPG saved as high quality in Photoshop increases the file size?

If you have a low quality JPEG which you open and re–save with 100% quality (or 0% compression) in any image editing software, the output will be bigger in size than the source. In order to understand this, it is good to take a crash course on JPEG.

JPEG compression isn't comparable to ZIP compression: ZIP works both ways—you can compress and later decompress to have the original file back.

JPEG compression, however, is a one-way job. Roughly speaking, during the encoding of the JPEG file, the image is split to 8×8 px blocks, from which a kind of spatial frequency spectrum is created by discrete cosine transform. After transform, the amplitudes of the frequency components are quantised.

The quality setting will (roughly) determine how much quantisation will be made. What gets lost in quantisation is long gone. Some further compression will be applied, but from this point forward it is usually lossless.

Now, when you open the encoded JPEG image in your favorite image processor, the JPEG gets decoded. If the JPEG isn't encoded with a lossless setting, you don't have all the same details as the original JPEG had: remember—some bits of data has been lost i.a. during the quantisation. As JPEG is encoded block–by–block the compression appears in the decoded image as jaggedness and JPEG–artefacts. Also some colour & brightness information has been lost.

When you save this decoded JPEG file again, the image processor's JPEG encoder does not take into account whether the file has been compressed before or not—it just encodes it as it would encode a lossless file, i.e. every pixel should look as every pixel looks like. When using 100% quality / 0% compression setting, the encoder will try as hard as it can to preserve all the details—and that includes all the jaggedness, artefacts, color & brightness data as they are.

The file size increases because the actual compression is not the jaggedness or the artefacts. The compression is the rounding and quantisation of the "instruction set" from which the JPEG is decoded and rendered to your screen.

In other words, you don't decrease file size with great effect just by making the image look more jaggy or by adding artefacts. This means that if you save a jagged JPEG with the best quality, its size will not greatly differ from a non-jagged JPEG saved with the best quality.

Again: the JPEG encoder assumes its input is lossless and when you open a compressed JPEG the rendered image (what you see on your screen with all the jaggedness & al.) will be the "lossless input" for the encoder.

The problem is, I have this background and want to add a logo image over it, and then save it. But If I do so, I have to save this with 10% quality, and the logo looks horrible. If I save this to 100% quality, the file size is huge.

There is a lot of options between 10% and 100%! In the dialog that allows you to set the JPEG compression, you can choose it to preview the output. This, for one, allows you to visually inspect which would be a good setting.

Other good option, as many of users have already suggested, is to use Save for Web & Devices… dialog, which allows you to preview not only different JPEG compressions, but also how your output would look if you convert the image to PNG-8, PNG-24 or to a GIF image.

A PNG-24 image is lossless and in many cases beats JPEG when the source image is not photography–like: shapes and solid/predictable areas of colour are areas in which PNG will excel. As you have a logo on a background, it might be a good option. Of course the artefacts from the low-quality JPEG-background will be included in the output.

The best option I would suggest (as the question is migrated form webmasters.se) is that you leave the background as it is and save the logo as transparent PNG-24. Then you position the logo on top of the background with CSS. You retain the quality of the logo and will not cripple the JPEG background more.

7
  • I don't think this explains the situation: I have no problems with your explanation per se, it is just that the reasoning behind the file size change is that when the file is opened in photoshop, it is not compressed AT ALL, and when you save it again, you are compressing an uncompressed image (again). Compression is a method for file storage and transfer ONLY. If you can see it with your eyes, it is not compressed.
    – horatio
    Commented Nov 30, 2011 at 22:52
  • I was trying to distinct the terms decoding and decompressing. (Noting the confusion—maybe I was too maverick.) It is not a decompressed image that the applications shows, but rather a decoded JPG that is rendered as good as the source allows. Compare to a plot drawn as a vector: the rendered output is only as accurate as its function. However, the plot will be drawn at max quality; correctness of the function is disregarded and it is just being drawn as good as possible. Commented Dec 1, 2011 at 10:50
  • Koiyu, great explanation, however, there is something I don't quite understand. for example, I open a 500Kb image and save as x% quality jpeg, resulting a 200Kb image. Now I open the image again, change nothing, and save it 100% quality. Shouldn't it be the same size? even more, if I use, let's say, 80% quality, maybe the algorithm creates some new artifacts and the file size changes. but if the image is 200Kb, and as you say, the "missing information" is long gone, why the algorithm "add" more bits to the image, resulting in a bigger image? Commented Dec 1, 2011 at 14:04
  • @Alex Angelico, No, it shouldn't be, because when you open it, it is no longer compressed, and recompressing it starts from its UNCOMPRESSED size. In a simplistic sense, you can have an IMAGE that requires 10MB of memory and you can save it to a FILE with compression such that FILE size is 1024K. When you reopen the FILE, the IMAGE is still 10MB.
    – horatio
    Commented Dec 1, 2011 at 14:36
  • @horatio but if it's loseless compresion, you cannot uncompress it. What's gone it's gone. Commented Dec 1, 2011 at 14:54
1

Have you tried flattening the image then going to save > save for web? 'Save for web' gives you more control over the output size plus lets you see the quality change with each setting.

There are online services such as http://www.smushit.com/ysmush.it/ , which might help squeeze some kb's out of your images.

0

I ever face this problem. So for the solution. I open the file in photoshop > Do whatever change i want > go for Save for web with 100% quality > see its preview in web browser instead of saving it directly > Now i save it from the browser > Then i finally compress the image file with some separate tool.

0

As stated, that's how JPG compression works.

If you're trying to compress large areas of a JPG but not others, then you want to use selective compression...something I've only seen available in Adobe Fireworks software.

-1

Convert the image into a smart object first and then expand the image. This will help in preserve quality. When you have added the logo over that image, press ctrl+alt+shift+S. This will help you save for web devices. Choose the quality(after checking the output quality on the right and the file size at the bottom). You should have a fairly compressed jpeg.

Also, when photoshop opens a JPEG compressed image, it decompresses it. And when you save it at it highest quality, it saves it without compression. Hence the difference in file sizes.

6
  • +1 for visual evaluation, but -2 for "JPEG decompression", Photoshop doesn't do such a thing when opening a JPEG—all the artefacts are certainly there. Commented Nov 30, 2011 at 10:57
  • how photoshop decompress the things??????????/
    – Jack
    Commented Nov 30, 2011 at 11:02
  • 1
    Photoshop does indeed decompress JPEG images when you open them - it needs to in order to display them! But it also always compresses them when you resave them. How changing quality settings affects the actual byte size of the file is a separate issue.
    – e100
    Commented Nov 30, 2011 at 12:12
  • @e100 I wouldn't call it decompressing; decoding or rendering would be more accurate term. Commented Nov 30, 2011 at 12:20
  • Well, it is decompressing whether you like it or not - it has to be internally stored as 24 bits per pixel.
    – e100
    Commented Nov 30, 2011 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.