Showing posts with label Software. Show all posts
Showing posts with label Software. Show all posts

Wednesday, 8 June 2011

Windows 7 Tips for the OCD

If like me, you are mildly OCD (or perhaps pedantic is more accurate), then you might appreciate these little bits of information that will help make your Windows 7 UI a little more pleasing to the eye.

If you have a large, high resolution screen, you might notice that Windows 7 doesn't look so hot in places, such as the login screen background being very low resolution and suffering from JPG artifacts.  Similarly, if you have decided to change the default user icon/avatar to something of your own, you might find that it looks a little blurry compared to the preinstalled icons.

Fortuantely in my fiddling and tweaking with Windows 7, I've come across some work arounds and information that will improve this situation.

Windows Login Icon
If it's one thing I like, it's a crisp image.  It has been a habit of mine to make sure I get the dimensions right when creating avatars and icons to avoid them being rescaled.  In fact, this is basic and you no doubt already take this into account when selecting or making desktop backgrounds.

I googled around at first to save myself the trouble of trial and error, but all information was pointing to the icon size being 128x128 pixels.  I created my icon with those dimensions and it didn't look as sharp as the supplied icons - I could tell it was being rescaled.  I managed to find a screenshot of the Windows 7 login screen and measured the dimensions of the user icon space in Photoshop.

It turns out the correct dimensions for the Windows 7 user icon at the login screen is 126x126 pixels.  I'm now using a 126x126 PNG as my login icon, and it's pixel perfect, no rescaling anymore.

You might want to note that Windows Live Messenger uses 96x96 pixels icons and also accepts PNG.

Desktop Background
It actually wasn't until last night that I noticed this.  I've been using a scan of some Ocarina of Time 3DS promotional art as my background for a while, and I found a high resolution PNG of it on the Nintendo E3 press site, so I decided to recreate it as the original had some weird artifacting around Ganondorf's hair despite the image being very good quality.  I didn't know why and presumed they were scanning artifacts.

After I had cropped and downscaled the new image, I saved it as PNG and applied it, but the weird thing was is that my recreated image didn't look as good as the image I was replacing.  If anything, Ganondorf's hair looked worse now than before, and I thought I saw some JPG artifacts around Link's ear.  That set some gears turning upstairs, so I pulled up the original PNG in window and compared them.

Left: Original PNG, Right: Original when set as wallpaper in Windows 7.  Notice the artifacts around his ear.

Sure enough the background appeared to have JPG artifacts and was evidently lower quality than the source file despite the fact that the source was a PNG.  It turns out that Windows 7 converts BMP and PNG wallpapers to JPG, and after a quick google, I found it stores them in "%appdata%\Microsoft\Windows\Themes" (paste that into an explorer window, or press the Windows key and R and paste it in there).

Saturated colours are a huge giveaway.  Who at Microsoft thought it would be a good idea to convert lossless wallpapers into JPG of this quality?
Fortunately there are two workarounds for this.

Method 1
Windows will recompress BMP and PNG images to a lower quality JPG, but it does not recompress images that are already in the JPG format, it simply copies it to the themes folder in %appdata%.  Open your BMP or PNG wallpaper in something like Adobe Photoshop or GIMP if you need a free alternative, and save it as JPG using the highest quality setting.  It's not lossless, but it's so good I doubt you will be able to tell the difference.  Apply the wallpaper in the usual way.

Method 2
This method will allow you to use a lossless background (eg BMP or PNG) without ever converting it to JPG.  Just get your image, drop it into an open Firefox window, then right click and choose Set As Desktop Background.  The only real down side to this is that Firefox converts it to a 32 bit BMP, which uses around 8MB for 1080p.  Ouch.



Microsoft, if people select BMP or PNG as a desktop background it's because they want a lossless image.  Don't go around compressing it to a shitty JPG.  My computer is supposed to do as I tell it to, not what someone else thinks is good.

Replacing the Login Screen Background
When I was testing the Windows 7 RC, I noticed that the login screen background was horribly stretched and full of JPG artifacts.  It irritated me, but I let it slide, and assumed they would put lossless backgrounds in for the retail version.  Well it didn't happen.  When I bought my Vaio at the beginning of 2011, it was the first time I had used a full retail version of Windows 7, and I was surprised to see the same low quality background.  It felt like a downgrade, because Vista certainly didn't have JPG artifacts, and I'm pretty sure the Windows XP login, as simple as it was, didn't suffer any quality issues either.

But one day my sister got a new laptop and to my surprise it had its own branded login screen.  The quality was really good too.  This gave me hope.  I had previously not even considered the possibility of changing the login background because I presumed it would be hidden deep within the system files and be tied up within a DLL, a locked file or something that wouldn't be worth the effort changing.

One of the workarounds for the low filesize limitation is to decrease the brightness of the image.

I googled it anyway and it turns out it's stupidly easy to change the login background, however there are a couple of limitations:
  • The image type must be JPG
  • The file size must not exceed 249KB (256,000 bytes)
  • Must be named backgroundDefault.jpg
Unfortunately a filesize that low can impact the quality for large resolutions, but there are a few tricks to help with that which will come later on.

How to use a Custom Login Background
1) The first thing you need to do is download this registry entry.  You may need to show the file extensions in Explorer and delete the .txt that mediafire seems to have added to it (so it ends in .reg).  Double click to add it to the registry (or right click and select merge).  This tells Windows 7 to prefer custom backgrounds over the OEM background.

2) Open an explorer window and navigate to C:\Windows\System32\oobe\  At this point you may need to create another couple of folders if  they don't already exist.  Right click and make a new folder called info within the oobe folder.  Open the info folder and make another folder in that called backgrounds.  Once you open the backgrounds folder, your path should read C:\Windows\System32\oobe\info\backgrounds

3) At this point we need to prepare/compress the image.  To prevent scaling of the image (which is what gives the default login background that pixelated appearance), you need to make sure the image is the same resolution as your display.  Right click your desktop and select screen resolution to find out the dimensions of your display, and match these dimensions if you are downscaling or cropping an image in your photo editing software.  If your image is smaller than your display, it is generally better to upscale it in your photo editing program than let Windows do it.

When you have the image at the correct resolution, it's time to compress it.  We need to get the filesize under 249KB, but at the same time squeeze every last bit of quality out that we can.

For Photoshop:
To save the file, click File > Save for Web & Devices.  This gives us much finer control over the JPG quality levels than the usual JPG export under File > Save As.  Select the Optimized tab to see a preview of your compressed image and then pick JPEG high from the presets in the top right corner.

The Photoshop Save for Web and Devices export screen

Taking note of the filesize in the lower left hand corner of the window, adjust the value in the quality setting (in the top right) until you get close to 245-250KB.  You can also experiment by checking and unchecking Optimized and Progressive as these will usually save you 5-10KB for free.  If embed colour profile is checked, uncheck it.  When you have reached your target filesize, hit save and put it on the desktop for now.

For GIMP:
To save the file in GIMP, click File > Save As.  In the save dialog that pops up, change the extension to .jpg and press enter (just save to the desktop for now).  This will take you to the JPEG compression options.  It's similar to Photoshop in that you have a quality slider with fine control over the amount of compression.

Check the box that says Show preview in image window.  This will enable a preview of the image quality after compression, but more importantly the filesize.  Move the slider left or right until you get to around 245-250KB.  You can expand Advanced Options to gain access to things like Optimise and Progressive which will save a few KB without affecting the image quality.  There are also advanced options such as subsampling which controls how the colour is encoded.  If you are saving a JPG to use as a desktop background like earlier, I'd suggest using the highest quality level, and setting the subsampling to 1x1,1x1,1x1, but for the purpose of the login background, you might want to experiment with the other subsampling options.

4) Once you have your compressed image, it's time to move it to the C:\Windows\System32\oobe\info\backgrounds directory.  The image should be named backgroundDefault.jpg.


Providing you applied the registry entry successfully and got the filesize small enough, your custom login background should now show when you Ctrl Alt Del or lock your system with Windows key and L.  If the background does not show, you might need to reboot.  If it still doesn't work after that, compress your image so it's a little smaller (I read the limit is 256KB, but it appears to be closer to 249KB or 256,000 bytes.

Once the registry entry is applied, you can change the backgrounds in real time without reboots by just changing out the image stored in the backgrounds folder as long as it has the same name.  If it doesn't show, it's likely to be a filesize issue or the JPG settings (eg Windows doesn't like the subsampling or optimisations the program uses).

Disabling the Boot Logo
I had used Windows 7 on a 4:3 laptop (1400x1050) for quite a long time, maybe over a year, so imagine how many times I have seen the boot logo.  Well now that I have a widescreen laptop, that boot logo simply annoys me.  Why?  Because it's the wrong aspect ratio.  Apparently Microsoft can cram their OS with 10GB of redundant crap, but they can't be bothered to put in a boot logo for widescreens.

It's not as if widescreens are anything new either, and they are only becoming more popular as time goes on.  Well there isn't really a fix for this, aside from unpacking a system file and resizing 105 or so images.  It's just not worth the time (even if I automate it) and not worth the risk of screwing something up.

So my solution is to not look at it at all, and here's how you can do the same.

1) Press the Windows key and R.
2) Type msconfig and hit enter.
3) Go to the boot tab and check No GUI boot
4) Click Ok to confirm

Now the next time your computer boots, it just shows you a black screen (with some weird little dotted lines in the top left corner as it loads).  I found that skipping the boot animation speeded up my boot by about 5 seconds, so it's a win-win.

The only downside to this is that I rebooted to run a surface scan on my HDD once, and because the GUI did not load, it just ran the scan with nothing on screen so I had no idea what point it was at.  That wasn't too bad since the program was automated, but it might cause some problems if you ever require user input.

Friday, 29 April 2011

Firefox Quick Tip

At some point you will have come across a website that resizes or moves your browser, sometimes it can be in the form of those annoying popups.  I recently came across this when watching a news stream from Japan covering the Fukushima nuclear plant.

Well here's how to stop those sites hijacking your browser positioning.

Click Tools, then scroll down to Options.
Select the tab Content from the top.
You will now see some options.  Look across at the one that says javascript and click Advanced.
Uncheck the first option Move or resize existing windows.

That's all there is to it.  You can test by loading this site.
http://www3.nhk.or.jp/nhkworld/r/movie/index.html

Thursday, 7 April 2011

uTorrent Tuning

For most people, the default settings in uTorrent will work fine.  You will generally max out your connection before you hit the maximum number of connected peers for example.  However I have recently upgraded to 50Mb/s (6MB/s) fibre optic broadband, and found that I wasn't getting the most from my connection.

One thing I found is that I was connecting to the maximum default number of peers and still not maxing out my connection.  Consider this:  If you can download at 6000KB/s, but your software is set to connect to a maximum number of 100 peers, what happens if the fastest they can upload is 30KB/s each?  That's right, you connect to 100x30KB/s peers, and you only achieve 3000KB/s download (half your maximum throughput).  It's even more of a problem on connections such as 100Mb/s where the downstream is approximately 12MB/s.

One real life scenario was when I was downloading an episode of Nichijou.  I had already set my max connected peers to 150 from previous.  I left it to download in the background while I chatted in IRC for a little bit and then thought to myself, "Why hasn't it finished yet?".  It hadn't finished because I had connected to something like 135 seeds and 15 peers and was only managing to pull 800KB/s (new torrent).  I upped the limit to 200 just to see if it would help and although it didn't connect to 200 (maybe 180 in total), I got 3.8MB/s.  It's definitely worth adjusting your maximum connected peers if you have a good connection but rarely get your maximum seeds on well seeded torrents.

Then I ran into another problem.  When you start downloading a torrent, the default action is to write that file to disk and fill it with zeros.  Kind of a placeholder for the file if you like.  For MP3 albums and small downloads, it's not a big deal because your HDD will have written the file before you've had time to connect to all your peers and reach a high download speed.  The problem arose when I was downloading an OpenSUSE DVD ISO.  uTorrent wanted to write 4.3GB as soon as I had started the download.  It took a little while to write this, during which time I had connected to all my peers and hit 6MB/s download.  Because the HDD was busy, I got a disk overloaded 100% warning in uTorrent and my download speed dropped drastically (a few hundred KB/s) since the HDD couldn't keep up with writing the file at maximum speed, plus the stress of an extra 6MB/s.

Writing the file and zeroing it out when the download starts is annoying.  Not only will it cause your download speed to drop, but it also has the potential to cripple your system for a good few minutes.  What happens if you download a 50GB Bluray ISO?  It would take a good 15 minutes at least to write that at full speed, during which time I doubt you could load much else.  Fortunately I found two methods within the uTorrent settings that help alleviate the problem.

Another annoyance that can hinder you from reaching your full speed is traffic management.  An automated system that checks the packet headers to see what type of data it is.  If it detects torrent traffic, it throttles the speed.  You can work around this by using encryption in uTorrent.

So now let's move on to the actual tuning.  I use uTorrent 1.6, but these options are pretty much universal.  Click Options > Preferences to get started.

Downloads
Click the downloads tab, and ensure "Pre-allocate all files" is unchecked.

Connection
Bandwith Limiting
Did you know that uploading at your maximum speed can cripple your download speed?  The latest versions of uTorrent set your maximum upload speed to 80% of what you can actually achieve to prevent that happening.  If you don't know what your upload speed is, go to Speedtest, pick a local server and make a note.  Multiply your rating in Mb/s by 128 to get your upload rate in KB/s.  Then multiply that by 0.8.
Eg.  4.7Mb/s * 128 = 602KB/s * 0.8 = 481KB/s
Your result is what you should set your Global maximum upload rate to.  Check the box for Alternate upload rate when not downloading and set the KB/s to 0 (unlimited).  With these settings your downloads will not be crippled, and when they are done uTorrent will seed at maximum speed.

BitTorrent
Number of Connections
This will control how many peers you can connect to.  Take a look at the image below
Here you can see that under the Seeds heading, it says 119 (845).  What that means is that I am connected to 119 seeds out of a potential 845.  The same applies for the Peers heading (connected to 6 peers out of 126).  You will see that the setting Maximum number of connected peers per torrent controls how many seeds and peers your are able to connect to.  In this case my limit is set to 125, and uTorrent has decided to connect me to 119 seeds and 6 peers.  Fortunately for this torrent I had reached my maximum download speed, but there are occasions where you will connect to your maximum number of peers and still not reach your maximum speed.  In this case, increasing the maximum number of connected peers should help, providing the number of seeders in the brackets is larger than the number you are already connected to.

Be aware that setting this number too high could have adverse effects, so it's a case of trial and error.

Protocol Encryption
Setting encryption to Enabled and Allow incoming legacy connections will encrypt some of your traffic.  This is particularly useful if you suspect your ISP is throttling your torrent traffic as it scambles the data and makes it unreadable by bandwith management systems.  Again this is another setting that you should experiement with.  You could set encryption to Forced and uncheck Allow incoming legacy connections for full encryption, but it will also limit the amount of peers you can connect to.  It's probably better to have a little encryrption and a little throttling than full encryption and less connected peers.

Advanced
net.max_halfopen
This option specifies how many connections uTorrent should try to establish at any one time.  The default is 8 which is very low.  I have mine set to 100.  The theory behind this is that it will take less time for you to connect to all your peers and reach your highest speed.  Before tweaking this, I found that for files in the region of 200MB, that it would have completed before I had connected to all the peers and reached my full speed.

Users of XP SP2 or later should patch their tcpip.sys file to make the most of this increase, as the max number of halfopen connections was reduced.  More information can be found here.  This limitation was again removed in Windows Vista and Windows 7.

gui.update_rate
This won't affect your download speed but simply changes how often the data reported by the GUI is updated.  The default is 1000ms (1 second) and the lowest you can select is 500ms.  Any lower figures will be igored and 500ms will be used.  I prefer having it update at half second intervals, but if you find CPU usage is high, you can set it to update less frequently if you wish.

bt.connect_speed
This option specifies the number of connections uTorrent should make each second up to the limit set in net.max_halfopen.  The default is 20, and I set mine to 40.

diskio.sparse_files
This is an important option as it controls how the data is allocated on your hard drive.  If False is selected (which is the default), then uTorrent will write a dummy file to the hard drive as soon as you add the torrent, but fill it with zeroes (the place holder file as explained earlier).  This is fine for small files that can be written in a few seconds, but for large files like Bluray rips it can cause your drive to be busy for a long time, and the download speed will likely drop during this process as the HDD can't keep up with the incoming data.  It may also cause programs to become unresponsive.

Setting this option to True (as I have done) will inform the filesystem of the size of the file, but will not physically zero out the data.  Instead the only write operation uTorrent performs are writes for data actually downloaded.  This not only saves your computer becoming unresponsive when adding large torrents, but also means that the hashing process for incomplete files is much faster as it only hashes what has been downloaded, rather than a full size pre-allocated file.

In my opinion True should be set by default, however there are some limitations regarding the support of this mode.  It apparently only works on partitions formatted as NTFS (as opposed to FAT32 I suppose), however I can't speak of other filesystems such as EXT3.  Also if you are using a non-administrator account with a disk quota, sparse files won't work and it will still be allocated.

I encourage you to at least try this option if you've noticed high amounts of disk activity or unresponsiveness when adding large torrents.  This completely cured it for me.

Advanced - Disk Cache
Providing you set diskio.sparse_files to true, you don't really need to edit any settings here, but in case you couldn't (due to filesystem limitations for example), then these settings will help ease the pain of the file allocation stage.

These settings are fairly self explanatory, but most people rarely think about changing them.  I have done a little experimentation and find that the settings above give me the most preferable disk access.  Rather than writing data constantly, it stores it in RAM and writes it in chunks of about 80MB, or whatever your HDD can write in the space of a second.  If I'm downloading at my maximum speed, this means time between writes is 13 seconds plus, rather than the HDD writing 6MB every second.

You can check read and write patterns yourself in uTorrent.  Simply click on the Speed tab in the lower half of the window (the tab that gives you a upload and download speed graph) and change it to show disk statistics.  You can now see a bunch of cool stuff like how the cache is being used, how regular uTorrent is reading and writing to the HDD, and the throughput.

One setting I suggest you do experiment with is the cache size.  While the settings above should be good for everybody, the amount of RAM you have to spare for a disk cache will vary from user to user, and the amount of RAM you will need to allocate to make a decent buffer length depends directly on your download speed, ie a 1MB connection will require a lot less RAM buffer than a 6MB connection if the HDD is busy/unwritable for 2 minutes.

If you have a fast connection and download large files, I strongly suggest setting Override automatic cache size and specifiy the size manually to whatever figure you are happy to use.  This acts like a buffer in case the disk is busy and data cannot be written (a good example being the file allocation at the start of a large torrent, or if you do video editing etc).  The downloaded data is stored in RAM, instead of the download speed being dropped to a rate the HDD can handle.  Once the HDD becomes free again, the data stored in the RAM is then written to the file.  It's a lot more efficient than dropping the speed and/or disconnecting from peers and then reconnecting once the HDD becomes usable again.

You can calculate an effective cache size using the typical size of files you download and your maximum download speed.  Let's say that my system is set up to allocate disk space to new torrents and that I want to download a 4GB Linux ISO.  For the purpose of this example we'll say that my drive can write this file at 35MB/s - that means it would take 115 seconds to complete.  That's 115 seconds of the HDD thrashing and not being able to download at a decent speed (I'd usually get figures under 100KB/s when the disk was overloaded).

I know that I can download at a maximum of 6MB/s, and that I need to store this in RAM until the allocation has been written (115 seconds).  So 115s * 6MB/s would give me a value of 690MB.  In other words during the time it takes to write the pre-allocation, I could have downloaded 690MB, but without the buffer this wouldn't have happened.

And that concludes our uTorrent tuning.  If you find any better settings, please post them below