Since 1 pixel images are primarily used in e-mail to tell the sender that it has been recived, I was wondering if there was a way to block them (not like there is something to see there anyway) through an extension in chrome.

In addition, an alert that an image has been blocked would be preferred, but not necessary.

Chrome version: 14.0.835.18 dev-m (I don't think this really will make a difference, but it can't hurt.

  • What kind of e-mail? Gmail blocks images by default unless you've clicked "always show images from this sender." – user9528 Aug 8 '11 at 2:43
  • I want to see all images other than those that are 1 pixel in size. – soandos Aug 8 '11 at 2:45
  • 1
    Keep in mind that there are a number of reasons for a 1 pixel image. They are often used as spacers (after "stretching"), eg. – Daniel R Hicks Aug 10 '11 at 16:28

I'm not sure this is feasible. For one thing, how can you check an image is only 1 pixel if you haven't downloaded it?

One way might be to have a server check it for you, and hope the guy trying to log you is only checking which IP the request came from. But, if the image is uniquely sent to you, he can check if the image has been downloaded at all. I don't see a way around this. This is why all images are blocked by default on most mail clients.

UPDATE: It might be possible to filter out some 1px images though. You can look in the width and height attributes of all the tags in the document and check if they are 1. This is not guaranteed to work as these attributes are not necessary, but it's worth a try if you really need the functionality.

Something like:

var images = document.getElementsByTagName('img');
for(var i = 0; i < images.length; i++) {
    if(images[i].height == 1 && images[i].width == 1)

You'll probably have to edit this a little bit. I haven't tested it.

| improve this answer | |
  • Its not in the header or something? – soandos Aug 7 '11 at 2:50
  • 1
    What’s in the header of what? The dimensions of the picture in the header of the graphics file? Yes, for most graphics formats, the dimensions are in the header. So what? You’d still have to download the file to read the header. Unless you mean in the header of the email message, in which case, no, the dimensions of the picture are not in the message header because as far as the email format is concerned, it is not really a picture, it’s just a file attachment, and only the size/length is included. – Synetech Aug 8 '11 at 3:18
  • 1
    And that’s only for messages with attached pictures. For messages that are simply HTML emails with links to external graphics files, the email has even less way of knowing the dimensions of the graphics (by which I mean absolutely no way without actually downloading, which of course would defeat the whole purpose). – Synetech Aug 8 '11 at 3:20
  • @soandos Yes, there is metadata in images in the form of EXIF. But that is also stored in the image file itself, not in the MIME of the email. Sorry :( – goweon Aug 10 '11 at 15:46

You can develop a Chrome extension, or even a GreaseMonkey script that access the DOM before it's being written, gets a list of all images (or elements) and deletes the ones with height ==0 and width == 0.

| improve this answer | |
  • I am aware, but I don't want to program one (if I did, then the question would be off topic). I was wondering if this was available somewhere, or a feature in another extension (like AdBlock). – soandos Aug 7 '11 at 2:20
  • Well, just use AdBlock and add the address/s you want to block. All content from listed addresses is blocked - including images. – Traveling Tech Guy Aug 7 '11 at 2:22
  • I have no idea who will be sending the images... – soandos Aug 7 '11 at 2:24

Have you considered reading your email in plain-text mode, or disabling automatic image download/display in your email client? Even Hotmail offers that feature, and it is much easier than trying to block all 1x1 images. In fact, a decent client (including Hotmail), does this intelligently. That is, they allow you to choose to display graphics that are included in the email as attachments, and block only external graphics that would need to be downloaded. Then you can choose either to go ahead and download and display them, or skip it and just keep that message in text-mode.

For the record, 1x1 pixel images are not only used as web-bugs. They are also used pretty much anywhere that requires a solid block of color because all you need is a single pixel, then you just stretch it to the desired dimensions. This reduces file-sizes and bandwidth usage.

| improve this answer | |
  • I want to see all the other images. – soandos Aug 8 '11 at 2:34
  • Like I said, the clients have a button or something that says something along the lines of View images in this message, Download images, etc. For messages you trust, you just click it and the pictures download and display. For messages you don’t trust, you don’t click it. – Synetech Aug 8 '11 at 2:50
  • Again, that's not what I want to do. I want to see all pictures that are "important" and skip the 1 pixel ones. I don't want to block all pictures or show all pictures. – soandos Aug 8 '11 at 2:51
  • Again, not all 1x1 pictures are bugs, and in fact, they are important if you want to see things correctly. (See any web-design book/site for information on this.) Besides, you wouldn’t see 1x1 pictures on message you trust, unless they are stretched. And for message that you don’t trust, you don’t want to see any pictures since they are all bugs of some sort, regardless of size. – Synetech Aug 8 '11 at 3:15
  • But I do want to see them. While I now realize that 1x1 images have other uses, I'm willing to give that up. – soandos Aug 8 '11 at 3:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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