How-To: Remove a (known) password from a PDF file in Linux

I had a PDF the other day which required me to enter a password before viewing it, which is something I’d never seen before, so being a chancer I just slapped enter and it worked (i.e. there was no password, or more accurately the password was blank). However, keeping a file in that state is just stupid, so I wanted the “password” removed – and it turns out that it’s dead simple to do in Linux.

Two Stepper

  1. Install qpdf with synaptic or the command:
    sudo apt-get install qpdf
  2. Issue the following command:
    qpdf --password=YOURPASSWORD-HERE --decrypt INPUT-FILE.pdf OUTPUT-FILE.pdf

    So, if your password protected pdf is called foo.pdf and the password is empty (i.e. “”) like in my case, you just issue something like this:

    qpdf --password= --decrypt foo.pdf foo-no-password.pdf

Job done!

How To: Remove all desktop.ini (or indeed any recurring) files in Linux

I spent a while going through my music hive today, just putting music I’d ripped and dumped into the New folder into the correct spot, placing all albums by the same band into a folder called the band name etc, and there’s a hella lot of desktop.ini and Thumbs.db files floating around. This might be useful for people running Windows, but I’m not (or at least not anymore, and not for a long, long time) – so lets be rid of them, shall we?

Blatantly Unnecessary Warning: Deleting files deletes files! Fo’ real, yo! So try out the “tester” script before unconditionally deleting things you might now want to! =D

Measure Twice, Cut Once

Before we delete files en masse – let’s check to see what files we’re opting to remove. To do this, and assuming we want to check what desktop.ini files we can remove, just enter something along the lines of the following into the bash:

find path-to-folder -name desktop.ini

For example, if my music is stored on my NAS at /mnt/Share/_Serva, then to check what files will be removed, I’ll enter:

find /mnt/Share/_Serva -name desktop.ini

After hitting return on the above, you should be given a list of instances of files called desktop.ini and we get to put our minds at ease that it’s not even thinking about adding any other files (such as mp3s or what-have-you) to the list.

Cease and Desist

Once we’re happy we’re going to remove only the files we want gone, to interactively delete all the desktop.ini files from a given folder and any subfolders (and by interactively, I mean it’ll ask you whether you want to delete each one), enter the following command into the bash:

find path-to-folder -name desktop.ini -exec rm -i {} \;

So in my instance, to interactively (i.e. I’d then have to confirm each delete) remove all instances of desktop.ini, I’d enter:

find /mnt/Share/_Serva -name desktop.ini -exec rm -i {} \;

If I wanted to automatically remove all copies of files named desktop.ini without confirming each deletion, then I can just strip off the -i switch, leaving:

find path-to-folder -name desktop.ini -exec rm {} \;

You can then do the same thing for Thumbs.db or any other filename just by substituting the appropriate details after the -name switch.

Done & done =D

P.S. Just for the record, removing the -i will make the deletion occur automatically unless the file is write-protected, but you can always sudo that away, just like the request for a sandwich.

Credits & thanks: MegaJim over on Ubuntu Forums.

How-To: Easily Remove the Vocals from Most Songs

2015 Shortcut: When I wrote this article Audacity didn’t have an automatic center-panned vocal canceling effect… but now it does, so rather than do the stereo-separate / invert-one-track / play-both-as-mono trick (and that’s pretty much all there is to it), you should be able to find the Vocal Remover option in the Effects menu – but it’s more fun / interesting and can give better results if you do it yourself! =D

Audacity now has a built-in center-panned vocal canceling effect.

I found this trick the other day whilst stumbling the Interwebs and thought I’d do a quick-write up w/ pictures to make it as easy as possible… For this exercise we’re going to be using a piece of free audio software called Audacity, which you can get for Linux, Windows and Mac.

The track I’m using in this example is the first 50 seconds of Ben Folds – Zak and Sara, where the voice kicks in at the 11 second mark, and the original sounds like this:

Once you’ve got a copy of Audacity for your platform of choice, fire it up and follow these simple steps to get rid of the vocals from most songs:

1.) Import Some Audio

From the menu in Audacity, choose File | Import | Audio and then select an mp3 (or any audio format Audacity understands) to work with.

Audacity - Import

2.) Duplicate The Tracks

We’re going to come back later and use the bass from this to give it a nice, full sound – but for now just duplicate your imported audio by going to Edit | Duplicate:

Audacity - Duplicate

Once you’ve duplicated the tracks, we’ll mute our copy for now by clicking on the Mute button to the left of the waveform as shown:

Audacity - Mute

3.) Separate Our Original Tracks, Convert To Mono and Invert One Of Them

This is the key part of the process: because vocal tracks on songs are commonly recorded as mono and then mixed into stereo – by separating the tracks and making them act as separate mono tracks, we can then invert one of them to have them cancel each other out! And since usually only the vocal waveform is identical (i.e. mono mixed to stereo) it’s only the vocals that magically disappear from the sound! Ha!

So, to start off we need to click on the little down-arrow to the left of our original wave form and select Split Stereo Track:

Audacity - Split Stereo Track

Once the waveform’s been split (so we can mess with both channels individually) double click in the lower of the two waveforms (the right channel) to select it all, and then from the menu choose Effect | Invert as shown:

Audacity - Invert Right Channel

Now for the last really important step – simply set both left and right channels to output as mono by clicking on the little down-arrow to the left of each waveform and selecting Mono. Don’t forget to set both of them to Mono or the magic won’t happen!

Audacity - Convert to Mono

With that done, give it a play and see what happens! With any luck, there won’t be any vocals in the track – so with my example, it now sounds like this:

You’ll notice at the end that the vocals come back (the backing singing etc.) – why? Because it wasn’t recorded as a mono source, and hence doesn’t get cancelled out by the inversion we did earlier – so this technique won’t work for all songs – only ones where the voice is recorded in mono and then mixed into stereo, which to be fair, I think it a pretty large swathe of ’em, and it’d be perfect for karaoke or something like this anyway because you’d want the backing vocals there!

If you wanted to know more about how this wave-form cancellation works, you can always look up Superposition of Waves, but I’ll leave that as an exercise for the curious =D

4.) Filter Our Original To Add Back The Bass

Update: BigFuz points out in the comments below that an easier way than using equalisation to filter our copy so that it only keeps the bass is to use a Low Pass filter and just enter a value of 200Hz or 250Hz (whichever works best for you). You won’t be able to add back both bass and treble with a single pass using this method, but you may not want or need to! To apply a low pass filter to the copy, you can just select Effects | Effects 1 to 9 | Low Pass Filter from the menu – too easy! Relatedly (and yeah, it’s a bit obvious, but I use this to keep track myself), a quick way to remember which way around low-pass/high-pass goes is to think that a low pass filter allows everything below the given frequency to pass through, so a high pass filter must allow any frequencies higher than what you provide to pass through.

The voice-cancelled audio above sounds pretty good, and the vocals are definitely gone, but in the process we’ve stripped out a lot of the lower frequency sounds (i.e. the bass). So remember when we duplicated our waveform and muted it right at the beginning? This is where it fits in…

Un-mute our duplicated (and still stereo) audio copy by clicking on the Mute button to the left of the waveform, double click on the waveform to select it all, and then from the menu choose Effect | Equalization as shown:

Audacity - Equalisation

When the equalisation window pops up, we’re going to filter it so that all sounds above 200Hz are stripped out. To do this, just click somewhere on the main part of the window and a white dot will appear, click again and another will – then click on them to drag them around until you get a shape that looks kinda like this:

Audacity - Only Keep Bass

Notice that I’ve dragged the bottom-left slider all the way down to get access to the full 120Db and not just the 30Db on the scale by default.

You might have to have a bit of a play to get it right, but all we’re really doing is saying “Leave anything with a frequency of 200Hz or less alone, but drop the volume of anything over that frequency by around 120Db” (i.e. remove it entirely!).

If you mute our top two mono tracks and play it back, you should get the filtered version of the stereo track with only the bass remaining, which for my example sounds like this:

5.) Un-mute Our Original Voice Cancelled Tracks

With the vocal-free (but a bit tinny) audio playing at the same time as our bass-only version, we get a pretty neat sound with good bass and no vocals! Result! =D

You can then just go to File | Export to save the finished vocal-free version to an mp3 or such, if you wanted to keep it.

Wrap Up

I’ve read that some people like to cut out the sections between 200Hz and 1000Hz or so (1KHz, although I’ve also seen people push it up to 6KHz) to keep the low-end and high-end sounds, but when I was playing with this I kept getting some voice creeping back into the mix. This could well have been because I was only dropping 30Db when I was messing around with it though – so go nuts and experiment if ya wanna!

The shape I used for that EQ setting was:

Audacity - Keep High and Low Only

With that all said and done, I hope you found this guide useful – I didn’t come up with the technique or anything like that, I just saw a 10 line how-to and had to mess around for half an hour to get it to work, so thought I could knock up a quick guide that shows how it’s done really clearly, and I hope you have fun with the technique!

Flattr this

How To: Seamlessly Remove Things from an Image in GIMP

Photoshop CS5 has a content-aware fill filter which will try to seamlessly remove objects from an image – and that’s great. But GIMP has the same functionality, right now – for free. And it’s a doddle to use…

I posted about a cleverly designed glass which spells out what you’re drinking through linking dots on the glass with the liquid colour the other day, but to get that image, I needed to do a little bit of manipulation first. For this example we’re going to be using GIMP with the Resynthesizer plugin (package name: gimp-resynthesizer):

1.) Get an Image to Work With

I wanted to use a picture of the glasses, but the bar across the top was too close to them for it to be a nice shot with enough white-space around it, so the first thing I did was just stab the Print-Screen key to get a screengrab:


Remember that to fill in the missing details, you need as much as possible of what should be there – that is, a very high background to selection ratio! If you have a picture of someone’s face taking up a large section of the image and you try to remove the face – where can the plug-in get data from to know what to replace it with? It can’t! So it’ll make a guess, and it’ll fail badly. On the other hand, if you have a large swathe of grass with a football on it, and you’re removing the football, the plug-in has all the surrounding image to consider when doing the replacement!

In this case, I kept as much of the background as possible in the image while I was replacing the section I wanted removed so the plug-in could use that data for replacing content.

2.) Select the Section to Remove

Because the bar is rectangular in shape, the rectangular selection tool was the easiest option to select it – if you’ve got a more ragged section then use the lassoo selection tool, or a quick-mask or whatever to get your selection; just make sure it’s pretty tight to what you want to remove…


3.) Run the Resynthesizer Plugin

Once you’ve got your selection (i.e. what you want to remove selected), just pick Filters | Map | Resynthesizer from the GIMP menu and use the checkboxes as ticked below:



4.) Admire Your Handiwork

The Resynthesizer plugin is a little bit curious, in that running it, then undoing it, then running it again will produce different results. The first two times I ran it on the exact same selection on the exact same image ended up with some artifacts of text being dragged in, but the third time did the entire thing cleanly.

If you end up with stray artifacts from other parts of the image, you can either re-run the resynthesizing process, or just select the artifacts and re-run resynthesizer on them to remove them (remembering to keep the selections tight to what you want removed).

And voila…


That’s pretty awesome… Kudos to Paul Harrison for the plug-in – that’s some killer code – what a guy! =D

How To: Remove Adobe Drive

Adobe Drive is in the default install list for CS4, and even if you deselect it, you still end up with the explorer context entries for it, which point at absolutely nothing. As there’s no separate remove option for Adobe Drive, and I’m not using Version Cue servers, you need to find another way to get rid of said useless, space-occupying junk. Like this one…

On 32-Bit Windows:
Go to Start | Run… and enter:

regsvr32 /u "%CommonProgramFiles%\Adobe\Adobe Drive CS4\ADFSMenu.dll"

Or on 64-Bit Windows:
Go to Start | Run… and enter:

regsvr32 /u "%CommonProgramFiles(x86)%\Adobe\Adobe Drive CS4\ADFSMenu.dll"

This will unregister the Adobe Drive DLL and get rid of the context menus in one fell swoop…

If you (wisely) didn’t install it in the first place and just want to get rid of the context menu entries, fire up regedit and delete the following keys:


Job done.

Source: here.