Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Automator: Change BMP to JPEG files

OK, 25 year software developer veteran, Automator newbie.

Problem: Create automator workflow to convert a whole bunch of Windows BMP files to JPEG.

Looks like the Preview "Change Type of Images" is perfect. But when I create a simple simple "Application" workflow with just this action I get an error every time: No result was returned from some part of this expression. (-2763)

I've also tried adding "Get Specified Finder Items" (which, oddly, Automator tells me I need to add even after I have added it ????). Same error.

Is it just me, or is Automator really this messy to use? It's a nice idea, but it doesnt really seem to glue together too well. Sigh.

Ideas anyone?

Thanks,
Tim

MacBook Pro, Mac OS X (10.6.1), 4GB RAM

Posted on Oct 28, 2009 12:47 PM

Reply
16 replies

Oct 28, 2009 1:58 PM in response to Tim Hill1

Did you try running in Automator as a WorkFlow? Both ways work on my system. If you open the bmp in Preview, is a SaveAs successful in changing the type?

Well I spoke too soon. jpg to bmp works, but bmp to jpg gets the same error as you. Opening in Preview and SaveAs works for either conversion.

Message was edited by: xnav

Dec 6, 2009 1:56 PM in response to Tim Hill1

I am running into this same issue too, and it is giving my recommendation to buy a Mac to my father for its "ease of use while doing family pictures" a big "black eye". I am really bummed about this personally as a workflow or folder action is so much more elegant than having to open a program and you could have it import directly into iPhoto after it was done..... Oh well......

Anyone found a work around or other options to get this done?

Thanks,
Brad

Dec 6, 2009 2:55 PM in response to anonmill

Granted, Apple's own actions should work better than they do, but I don't think it's that much of a "big black eye" (maybe more like a fat lip), since Automator (like AppleScript) uses other applications and utilities to do it's thing. GraphicConverter is definitely an application worth having, and it does have an Automator action that converts to JPG (that works - in Snow Leopard).

Dec 6, 2009 9:45 PM in response to anonmill

Just a few ways to make it work:
# Use the *Ask for Finder Items* action. This will present an open dialog box to choose files.
# Save a workflow having just the convert action as an application and using it as a droplet. Just drag and drop the files that need be converted onto the application icon.
# Use the command line utility sips since at the end of the day that is what's doing all the conversion anyway. E.g.
sips -s 'jpeg' /path/to/original/image --out /path/to/new/image
#//Need to at least change the extension for the output
This can be done from within Automator as well (I think) using the *Run Shell Script* action. [Manual Page for sips|http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManP ages/man1/sips.1.html]
I usually use the last method from within an AppleScript but I've also tested the other two methods and they work fine on my computer with 10.6.2.

Message was edited by: hungryjoe

Dec 6, 2009 11:06 PM in response to Pierre L.

even easier, write an applescript that gets Image Events to handle it:
tell application "Finder"
set theFiles to every file of folder "path:to:image_folder" as alias list
end tell
repeat with thisFile in theFiles
tell application "Image Events"
try
set theImage to open thisFile
save theImage as JPEG in file "path:to:savefolder:newfilename.jpeg" with compression level medium
end try
end tell
end repeat

Dec 7, 2009 10:01 AM in response to Pierre L.

Alright, maybe "black eye" was a little too much and I let my disappointment lead to some hyperbole.

At any rate the Applescript/shell script ideas sound like they will do the same thing. They are a little more in depth, but nothing overboard, and it makes for more fun/learning. I will give it a try tonight.

THANK YOU! for the suggestions and help.....

Feb 9, 2010 4:20 PM in response to twtwtw

As a footnote to this, yes you can do it in AppleScript but...

1. I have say as a veteran developer AppleScript is .. ahem .. not the most approachable of languages.
2. String manipulation in AppleScript is awful. And the sample script kinda dodges this by not doing what it should, which is to generate output filenames from input filenames. (I know this cause I've tried it myself when studying AppleScript).

I think the events model in OS X is fantastic .. it's such a shame that it's crippled by AppleScript syntax from h*ll.

--Tim

Mar 6, 2010 6:31 AM in response to Tim Hill1

Here is a shell script to convert images from any format(s) to another using sips:

#!/bin/bash
if [ -z "$2" ]; then
echo Usage: $0 new_format files ...
exit 1
fi
format=$1
if [ ${#format} -gt 4 ]; then
echo Invalid destination image format "$format"
exit 1
fi
shift
mkdir -p converted
sips -s format $format "$@" --out converted


Example:
convert_img.sh jpeg *.png *.bmp

This will convert all .png and .bmp images to .jpg images and place in them in a directory called "converted". The correct extension is automatically added.

If you want to also delete the original images after conversion, add the following to the end of the sips line:
&& rm "$@"


Message was edited by: derickswan

Automator: Change BMP to JPEG files

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.