Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an animated GIF that's about 2 MB large. When I open it in Photoshop CS 5, add a layer with a logo, then save it for web, its suddenly 4 MB large.

Why? There aren't more colors or anything, so why does the size increase?

The image in question is NSFW and I cannot post it here.

share|improve this question
    
Sounds like maybe the number of frames is increasing somehow - have you checked the number of frames in the output? – user568458 Mar 3 at 11:17
up vote 24 down vote accepted

Color number is just half the game. The other is to compress the picture after color reduction. This lossless compression, searches for repeated patterns in scanline order.

Long story, in short: When you add the logo you are increasing the image variability, entropy. Compression gets worse the more entropy there is in the image, as the computer can nolonger find as many repeated patterns. Thus doubling complexity of image roughly speaking doubles your file size.

share|improve this answer
5  
Minor nitpick: adding a logo does not "automatically" increase image variability (imagine adding a plain colored logo on top of a complicated image). Still, with having to guess what OPs images look like, it's the most probable explanation. – Rad Lexus Mar 3 at 10:54
    
@RadLexus No, its certainly possible to magically end up with no increase in file size. But in general adding things to a image tends to increase complexity which has a tendency to increase entropy. But no it certainly does not have to increase size but unless you engineered it not to it most probably will. – joojaa Mar 3 at 11:05
1  
No, it doesn't require magic or special engineering for the size to be reduced. The point @RadLexus is making is that when you add something to an image then you are actually replacing a part of the image. If the part you are replacing has higher entropy than the part you are putting in, then the total entropy is reduced (generally speaking). – Supr Mar 3 at 12:02
    
@Supr Yes that's true. But if you place the logo onto something that was not very busy you get the opposite effect. You, in general, dont want to slap a logo on the busiest part of a image otherwise its hard to read. BUt we dont really know other than it using more space. Please note: simple on complex may in fact also increase the size of the complex part, because there's nolonger room for its building blocks. – joojaa Mar 3 at 12:08

Although joojaa is mostly correct, actually GIFs do not use Run Length Encoding. They use the LZW algorithm.

Basically, this algorithm can take advantage of EXACT repetitions of horizontal strips of pixels. This works very well for solid colours and regular dithering patterns (e.g. checkerboard patterns).

However LZW can only "remember" 4096 different pixel strips, so the more variation in your image, the shorter these strips are on average, and the less compression you get.

The bottom line: if you simplify your logo (more solid colours & regular patterns), or "borrow" common pixel strips from the rest of the image within your logo, or change the colours of the logo to be colours that appear more frequently in the rest of the image, the file size should reduce.

share|improve this answer
    
Thanks for the contribution and welcome to GraphicDesign! Let us know if you have any questions – Zach Saucier Mar 3 at 2:38
    
Fair call re. RLE. As a solution I simply added the info from my answer into joojaa's answer then took my vote away from his/her answer and in turn gave one to you :) – Lamar Latrell Mar 3 at 3:22
    
Yeah, shouldnt post stuff after I went to bed. Anyway the exact composition of how the algorithm works is unimportant. Removed that section. – joojaa Mar 3 at 5:13
2  
@LamarLatrell Sorry for the confusion but i dont think how the compression exactly works is important on this forum. Just the general principle of less repeated patterns leads to bigger image much easier to apply in thinking. Less text and more understandable result. – joojaa Mar 3 at 5:18
    
Don't forget that GIF images' compression is dumb: each frame is compressed individually, instead of intercombining the changes between frames. Effective, it is like having n images shoved into 1. – Ismael Miguel Mar 3 at 18:14

As mentioned in other answers, any variation placed on picture that was previously more uniform will pessimise compression. Still I don't think that would yield a two times increase for a whooping 2Mb (unless your logo is literally as big as image itself).

It could be that original image had maximum compression and all unnecessary header/meta info removed and PS added lots of its own stuff or didn't use maximum compression. Try running your new gif through tool like gifsicle and see if it helps. If you don't really care about image format, you can try pngout+deflopt and see how big .png will be.

share|improve this answer
    
It certainly is possible that the image has some metadata in it. But if we must speculate, perhaps it is a animation in which case even a small logo interacts multiple times. – joojaa Mar 3 at 11:22

In addition to normal GIF compression on each individual image, animated GIFs can optionally apply math operations between the next frame and the already on-screen frame, and put smaller images in smaller areas on the image canvas.

So let's say you have an animated GIF with 10 frames, and it's a black and white stick figure walking across the canvas. The first image would be complete, fill the canvas, and have all the information needed as if it were a stand-alone GIF. The next "frame" might only consist of a smaller box that only updates the area that has changed.

With video animated gifs, this is more complicated. Due to dithering you often find that the entire frame changes, so it's going to be larger.

Some GIF optimization software can make significant optimizations if it starts off with a good video source. Further, the software can make some tradeoffs to improve (decrease) size but by compromising the animation - perhaps worse dithering, for instance.

If you start off with such a GIF, though, and change it, even in some small way, you can't necessarily expect the software (in this case photoshop) to be able to apply the same optimizations because it lacks the original source video. Further, it may not even store it internally in a way that allows it to recreate the original GIF with its optimizations. Try opening the animated GIF, then exporting it as a new animated GIF without making any changes. It's possible that the size increases simply because it's not using any optimizations and is storing each full frame.

Once you change the frames, you'll find that the size will increase anyway, even with optimizations. This is particularly true if you use an alpha channel and have some of the logo see-through or as a watermark with translucency.

You may be able to recover some of the optimizations by running it through a GIF animation optimizer software after photoshop, and a lot of people do this anyway, because photoshop values quality and pixel perfection over size.

The ideal solution, though, is to take the original video (not the GIF, but video file), apply the logo/watermark, and then use a GIF animation program specifically designed to optimize for size to do the conversion. Skip photoshop entirely.

share|improve this answer

Deducing from the size of the image I'd say it is an animated GIF and like Adam Davis said there are several more ways of optimizing animated GIF images than just static GIF images.

Now I'm not an expert with what exactly Photoshop does but it may try construct a GIF file where the static logo layer is overlaid on top of rest of the frames, where especially in case of very busy animation, i.e. movie clip, it might be better to define a 'coalesced animation' which consists of a sequence of complete image frames displayed one after another.

I only know how to do this with imagemagick but my guess is that in photoshop you need to merge the logo layer on top of each frame before saving the sequence.

share|improve this answer
    
Thank you, @zelluv. Yes, it is an animated GIF. I tried to merge the logo to each individual frame/layer, so that there would be no separate layer, but it did not change the file size even one Byte. – what Mar 3 at 14:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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