Convert PDF to image files

Another entry in my PDF series. :)

At work I had to convert a few PDFs into jpeg files. The PDF files actually contain just images, so extracting the images would’ve been as good, but converting PDF pages to images is easier. :) At least on windows. On linux you could use pdfimages, which should be available for your distro through some poppler util package.

A general approach is to use the versatile ImageMagick software. Using the convert command, it’s simply a matter of:

convert -density 200x200 -quality 85% inputfile.pdf outputfile%03d.jpg

to convert inputfile.pdf to a set of jpeg files. Of course you can choose any supported output format you like: png/bmp/gif/etc.. The density option is important as it specifies the output dpi which is only 72 by default. Imagemagick uses Ghostscript to do the pdf reading, so on windows you have to make sure that environment is set up correctly. In my case I had to add its bin directory to the path and set the working dir to the lib path as it didn’t find gs_init.ps otherwise (adding to the path didn’t help). If you know a better way, please let me know in the comments. I also specified the quality option to have a jpeg quality factor of 85, which is 75 by default.

Since I had to process a batch of them, I thought it would be nice to have a cool batch script to do them automatically. Here is what I came up with:

C:
set path=%path%;C:\programs\gs\gs8.54\bin
cd C:\programs\gs\gs8.54\lib
for %%C in (%*) do call :startconvert %%C
goto :eof

:startconvert
convert -density 200x200 -quality 85%% %1 %~dp1%~n1%%03d.jpg
goto :eof

Replace the paths as appropiate. To use the bat file, simply drag and drop one or more pdf file on the bat file. It will put jpeg files in the same directory as the pdf file and number them using 3 digits (%03d printf format). %~dp1 stands for the full path of the 1st argument file, %~n1 for the name only (without extension). Also note you have to escape all other %’s.

iTunes on linux

Read the update below!

I hate to admit it: today I created an iTunes store account. In my defense, I felt forced, as the CD I wanted to buy was only available as a physical CD and not in digital download form. It will probably become available in digital form in a year or so, but who wants to buy a 2010 compilation CD in 2012? ;) And who wants a jewel case CD which you have to rip anyway to have any use of it (besides gathering dust).

So today, once again, I gave installing iTunes on linux another try. I followed the google #1 guide which suggested to install an old version (7.2). Unfortunately, when you go to the store, it says it can’t connect or that the service is temporarily down or something. So I thought, wine updates every 5 breaths, I wouldn’t be surprised if it actually runs the latest version. Store connection works indeed in iTunes 10! I created a login from within iTunes, made a test purchase, and yes, we have lift off. :) I can see how iTunes is such a success. Just type in the search box, click and a few seconds later you have a high quality drm free mp4/AAC on your harddrive. Very tempting indeed. And the excellent recommendation system only encourages too of course.
A guide for converting to mp3 (or wave) from within iTunes can be found here. I don’t need that on the desktop, .m4a plays back fine, but my car lofi radio only plays mp3/wma.

I’m still a bit confused as to why the CD is only downloadable from iTunes and not form the publisher’s webshop. I guess they have an exclusive deal with Apple to only release the downloads after some time..

Update: The next morning I arrived at work and installed iTunes to download my newly purchased album. Surprise, surprise! iTunes does not allow one to redownload a purchased song!! It’s insanely unbelievable in this time and age, but yes, it is impossible right now. I guess most people don’t know any other way, but for a lot of gamers who use steam, it is the most ordinary thing to do.

Time Machine for Linux: Back In Time

Recently, I watched a vid about Apple’s Time Machine and was quite impressed. For the first time in ages, I was considering to try out MacosX, after all, you have to give them credit: they just keep innovating as no other computer company. The plan was quickly abandoned though, when I discovered it wouldn’t run on my newly bought AMD monster-machine (post about that in queue ;) ).

Anyhow, I searched some alternatives and somehow nothing as user-friendly showed up.. Until today I stumbled upon the solution by accident while I was checking out LinuxJournal’s tech tips! Quite interesting/entertaining stuff there btw. :) I’m talking about about Back In Time and considering the Ubuntu dev, it even has a KDE4 gui, yay! :)

Check out the LJ screencast and the LifeHacker article.

Opera 10 send mail problem

I just discovered I had a mail in my outbox I sent last week. It turned out one of my email accounts was not properly migrated from Opera 9.
I ran Wireshark and it seemed Opera was sending a wrong parameter with the EHLO command (which queries an ESMTP server for its capabilities). It sent EHLO smtpserver instead of EHLO myhostname. Of course the server replied this could not be the case since he was that host himself. =)
So I grepped the accounts.ini file to see where that information could come from. It turned out there was a fqdn property present containing the smtp server name which was not present anymore in a newly created account (yet it seemed to attach some value to it, apparently). So I simply deleted the fqdn property and all was solved. :)
Keep in mind, I am upgrading the same opera profile since Opera 7 so I guess my particular upgrade scenario has received less attention. ;)

drop dropbox

For some time now, I’ve been evaluating dropbox. From time to time, I need to be able to store a file and have it available at another location in a synced fashion. First some history.
Before Dropbox, I was (ab)using gmail through the firefox gspace plugin, but, 1) you need firefox 2) you pollute your mail space 3) it’s buggy and bloated 4) but still doesn’t have all features I want. The reason I chose gspace back in the day, was because it was presumably cross platform through use of the firefox platform. That turned out to become limited functionality and eventually useless at all (may be fixed by now). It had also issues with having your gmail open in a tab at the same time. So I looked for an alternative and dropbox seemed promising.

My requirements for a ‘online storage’ solution are:

  • cross platform native clients: to allow sharing between work and home computers.
  • web interface: when you’re in the wild at someone else’s computer where you don’t want to install a client.
  • corporate-proof: can operate from behind different types of proxies.
  • server-side backup: when you accidentally overwrite a file from another location, or when syncing fails to do the right thing.

My nice-to-have’s are:

  • revision history: same as server-side backup but extended to multiple backups.
  • desktop integration: status overlay (aka tortoise stuff), context menu to perform web actions, for example, revert to some revision, make public, …
  • exclusion filters: handy when you don’t want your lock or temp files (due to editing) to be uselessly synced all the time.

Dropbox seemed to fulfill all my wishes except exclusion filters. Until recently. :) At work, when I resume after suspend, the client doesn’t automatically sync back to the server (this can also be a proxy issue here at work, but it doesn’t work anymore and there’s nothing I can do about it, i.e. it’s closed source). But there are other things that bug me: 1) explorer integration is slow but not optional. So you have to live with it. 2) The (windows) client feels sluggish and quite heavy to load. 3) Linux client always lags behind and the desktop integration is only for gnome. Linux users had to wait long for a release, but even now, they are not treated very well. Then of course, there is the whole discussion of dropbox being closed source but the front-end part being open source, confusing people all around. :) They give the impression they care about the linux users and open source, but in reality, they can’t make it true. In fact, I have no problem using a closed client, but it has to work very well then. ;)
Dropbox has free and paid accounts. The free accounts are limited to 2GB storage and only 30 days history. No problem for me.
So up until recently, I was quite happy with dropbox, but since the windows client fails to reconnect after resume and the linux fails to start, I guess I’m counting its last days. :)

If anyone knows a decent cross-platform alternative, please let me know.

But it did raise that thought again in my head: why not try to start an open source online storage sharing solution? Is it so hard? Why does it not exist yet? Of course, I’m not targetting a system which can take loads and loads of people uploading their latest torrents to share with the rest of the family *rolling eyes* ;) But simply, you know, some system that can handle a few accounts (or even just private) which you can install on your own server and offers basic syncing functionality with some better-than-dumb compression/file-diffing mechanism. Personally, I also wouldn’t need fancy public web sharing like photogalleries and the like, so…

Maybe I’m missing something? :)

Thumbs.db viewer

Sometimes when images get accidentally deleted, even the thumbnails are already useful to view and might save you a recover operation. As you know, windows creates a hidden thumbs.db file in every directory where you viewed an image in thumbnail mode. When the file gets deleted, windows does not like to clean up (no surprise here), so you can still view them.
I found this nice free tool which simply does the job (.net framework required).


thumbs.db viewer