Shell script to convert TIFF to PDF under Mountain Lion

Bruce Pokras bruceap at comcast.net
Sat Sep 1 09:39:56 EDT 2012


Sorry, Mark, I don't know the answer to that. I don't have Mountain Lion and, in fact, cannot run ML on my "ancient" iMac from 2006. How would that work?


On Aug 30, 2012, at 10:18 PM, Mark Schonewille wrote:

> Hi Bruce,
> 
> Can't you use pids anymore under mountain lion?
> 
> --
> Kind regards,
> 
> Mark Schonewille
> Economy-x-Talk
> Http://economy-x-talk.com
> 
> Share the clipboard of your computer over a local network with Clipboard Link http://clipboardlink.economy-x-talk.com
> 
> 
> Op 31 aug. 2012 om 02:47 heeft Bruce Pokras <bruceap at comcast.net> het volgende geschreven:
> 
>> Last week I posted about a problem converting TIFF images to PDF under Mac OS X 10.8 (Mountain Lion). The old shell script that Ken Ray had posted several years ago and which had worked from Tiger through Lion simply did not work under Mountain Lion. That script used a shell command called "Convert" found at /System/Library/Printers/Libraries/convert. Several list members helpfully commented that Convert was no longer included with Mountain Lion, but it really was just an alias for another command called CUPSfilter. I located and selected Convert and chose "Show original" and it took me to /usr/sbin/cupsfilter.
>> 
>> Now the first thing that I tried was to send the same command that I had been using with Convert directly to Cupsfilter. That's because I felt that since Convert was merely an alias, it was simply passing the command to Cupsfilter and Cupsfilter was running it. Wrong! I don't know why, but all I got were errors messages in the It variable (or was it The Result). Whatever it was, Cupsfilter did not like the command that had worked for Convert.
>> 
>> So I went into the Terminal to try some stuff. First, I tried "cupsfilter" and received an example command and a list of options. One of the options was -m for the output file MIME type. However, there was no option for an input file MIME type. A Google search has led me to believe that Cupsfilter could identify the input file MIME type from its file extension. So I tried:
>> 
>> cupsfilter [input file.tif] -m application/pdf [output file.pdf]
>> 
>> What I received was an error message that the command could have only _one_ file name! That is very different from using Convert where both the input file and output file are named. So, OK, I'll use just the input file name and see what happens:
>> 
>> cupsfilter [input file.tif] -m application/pdf
>> 
>> I received different error message that said that cupsfilter could not determine the MIME type of the input file. So obviously the .tif extension was not being recognized. What to do? Back to Google!
>> 
>> After some fruitless searching I came to a page that had more Cupsfilter options than I had seen previously. This one had an _input_ file MIME type option, -i (duh!). I also found that PDF was the default output of Cupsfilter, so there was no need for the output file MIME type.
>> 
>> So back to the Terminal:
>> 
>> cupsfilter -i image/tiff [input file.tif]
>> 
>> Eureka!! The Terminal window was filled with commands and then a lot of gobblygook that started with %PDF and ended with %EOF and a message "INFO: cgimagetopdf (PID 35219) exited with no errors." In other words, it returned a PDF to the Terminal window!
>> 
>> So upon returning to Livecode, I found that the data was being returned in the variable "it" and it was simple to excise just the PDF data from the rest and write it to disk as a binfile. I double-clicked the file and up popped the PDF image. Whew!
>> 
>> So in Livecode all you have to do is use:
>> 
>> put "/usr/sbin/cupsfilter" into tConvertApp
>> get shell(tConvertApp && "-i image/tiff " & quote & tiffFile & quote)
>> 
>> and "it" should contain the data from which you can excise and save your PDF file.
>> 
>> Regards,
>> 
>> Bruce Pokras
>> Blazing Dawn Software
>> www.blazingdawn.com
>> 
>> 
>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list