Block all one pixel pictures in chrome

2

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.

soandos

Posted 2011-08-07T01:58:50.700

Reputation: 22 744

What kind of e-mail? Gmail blocks images by default unless you've clicked "always show images from this sender." – Kyralessa – 2011-08-08T02:43:18.310

I want to see all images other than those that are 1 pixel in size. – soandos – 2011-08-08T02:45:47.260

1Keep 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 – 2011-08-10T16:28:09.527

Answers

8

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)
        images[i].src='';
}

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

goweon

Posted 2011-08-07T01:58:50.700

Reputation: 1 390

Its not in the header or something? – soandos – 2011-08-07T02:50:54.280

1What’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 – 2011-08-08T03:18:11.197

1And 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 – 2011-08-08T03:20:47.170

@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 – 2011-08-10T15:46:11.973

1

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.

Traveling Tech Guy

Posted 2011-08-07T01:58:50.700

Reputation: 8 743

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 – 2011-08-07T02:20:27.123

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 – 2011-08-07T02:22:23.083

I have no idea who will be sending the images... – soandos – 2011-08-07T02:24:38.243

1

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.

Synetech

Posted 2011-08-07T01:58:50.700

Reputation: 63 242

I want to see all the other images. – soandos – 2011-08-08T02:34:01.300

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 – 2011-08-08T02:50:05.290

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 – 2011-08-08T02:51:44.507

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 – 2011-08-08T03:15:11.263

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 – 2011-08-08T03:20:27.060

You want to see external images in spam? Then you are going to get a whole lot more because when you download them, you have just confirmed to the spammer that your email address is a valid address that is actively being viewed by a person. – Synetech – 2011-08-08T03:22:24.080

@Synetechinc. let us continue this discussion in chat

– soandos – 2011-08-08T03:23:26.730