2

Automator would seem to the appropriative tool, but ehmac.ca is stumped and so has this board been so far — my "Automator Newbie" question asked yesterday (my first ever on this site). Two sticking points — changing the .tiff extension to .tif, and losing the Alpha option.

The problem to be solved is prepping a large collection of edited scanned text files in tif format and getting them ready for processing by the OCR app TesseractGUI 0.3. This OCR app balks at TIF files with an extension of .tiff, also balks at Alpha within the file format.

Here's the manual routine I've been using.

  1. Open the file in Preview.
  2. From the File menu choose the Export command.
  3. Click in the file name field and delete the second "F".
  4. Uncheck the Alpha option.
  5. Click the Save button.
  6. In the next dialogue choose the "Replace" option.
  7. Close the window.
  8. Rinse and repeat with the next file in the list.
  9. Exit when all files have been prepped.

Appreciated.

6

This works in my tests and should give you a starting point.

I use two actions to get the folder and its contents.

  • Get Selected Finder Items
  • Get Folder Contents

Then using a 'Rename finder items' Action. I change the extension with it's settings set to:

Replace Text

Find: tiff in extension only - ignore case Yes

Replace: tif


Then a 'Run Shell Scrip' Action using the unix command sips I change the format of the files to jpeg and then back to tiff. This removes the alpha channel.

It's settings are :

  • Shell: /bin/bash
  • Pass input: as Argument

With the code:

for f in "$@"
do

 /usr/bin/sips -s format jpeg  "$f"; /usr/bin/sips -s format tiff  "$f"

done

enter image description here

To use I select the folder with the Images and run the workflow on it. It will also work on a single or multiple images if that is what is selected instead of a folder


Update. User @chananelb pointed out that the is an Automator Action that can change the file type. But since they did not put any instructions in how this could be done. I will add it here as an alternative option.

The input of the service stays the same. And the first action as discussed in the comments should be Get Folder Contents.

All other actions can be removed and two actions of Change image type should be added.

The first Change image type is set to jpeg.

The second is set to tiff.

Thats it simple.

enter image description here Open bigger image


  • The concluding shell script fails with a "Contents not a valid file." The intent is to change tif into jpeg and then switch it back to tif in order to shack off the unwanted Alpha layer. I don't know Unix code. Can someone spot the error in the code? – user77681 May 18 '14 at 20:11
  • I'm confused by Mark's concluding instruction: "To use I select the folder with the Images and run the workflow on it." What's the procedure to run a workflow on a selected folder? Appreciated. – user77681 May 18 '14 at 20:28
  • The code worked on my test with no problems. I think I just selected the files and ran the workflow from automator but you can make it into service. I am sure I selected file that were not images to see if they broke it. But they did not. I am not in front of a computer at the mo. But will check it when I am. – markhunte May 19 '14 at 7:51
  • I'm not only working out how to solve this particular problem, I'm also learning this radically different "solutions forum". Challenging because virtually all the usual UI chrome is unlabelled and the feedback loop (so far) is this comment box. I'm starting to like it but have a lot to learn (about stack exchange) before I'll be really comfortable, or even proficient. – user77681 May 19 '14 at 22:06
  • I just made it a Automator service. By creating a service with input files and folders and removing the 'Get Selected Finder Items' action which the service input replaces. Agin worked with no errors. So I am not sure what is going on when you run it. Can you please tell me how and what you are doing. – markhunte May 19 '14 at 22:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .