Jan25

Joining many jpeg files into one single PDF

Tagged with: .
2 Responses

I had old scans of many guitar tab books as a directory of JPEG files, sequentially numbered. That was the way the old scanner stored documents. My SnapScan has an automatic document feeder and scans directly to PDF, which is much nicer to use. I wanted to join these JPEGs into a single PDF. After looking for different ways to do it, AppleScript, available software, etc., decided none of them were acceptable for my needs.

To accomplish the task, I used the following process (not optimal, but works):

cd directory
ls *.jpg | sort | xargs SavePDF

Where SavePDF is a program I hacked in an hour or so, using the CoreImage interfaces on the Mac. The code for SavePDF is shown below. Compile it with XCode, as of this writing Version 2.4.1

Precompiled binary for Mac OS X Intel platform is available here (in some browsers you’ll need to right-click and select “Save As…”)

Note that there is no error checking at all for the arguments. The resulting file is left at the current directory with the hardwired name “joined.pdf”

Use at your own risk – Works for me, YMMV. Other formats besides JPEG are supported by CoreImage and this code will work also with BMPs, PNGs and others. I personally have not used it for any other format.
(more…)

Aug19

Some interesting source code for Mac applications

Tagged with: .
Closed

While developing the iPhoto add in I found these interesting sources for several Cocoa classes.

Aug10

Export Plugin for iPhoto

Tagged with: .
Closed

Following up on my previous hack, I ended up writing a plug in in Objective C. It’s currently loading, not much frills. I’m deciding if I’ll try to reuse my Python code bridging with PyObjC or just rewrite in Objective C the export. Most likely the latter.

Here is a screenshot. When installed, my plugin nicely adds another pane to the iPhoto export options. It will export to a folder, just like Apple’s Web export plugin. The users can upload the folder to the webserver however they like.

Current user interface of my iPhoto Plugin

It borrows a lot of the UI from iTunes builtin web export (more than literally, because I copied a couple of things from the .nib). I hope to have time in the next couple of weeks to finish it. Looks promising, though.