Previous 1 2 Next 16 Replies Latest reply: Apr 20, 2010 12:39 PM by GanjoManjo
Tim Hill1 Level 1 Level 1 (35 points)
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
  • xnav Level 5 Level 5 (6,635 points)
    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
  • xnav Level 5 Level 5 (6,635 points)
    Looks like a Snow bug, see the comments [here|http://www.maciverse.com/automator-tip-of-the-week-picture-file-conversio n.html]. It was working for one guy on Leopard, but Snow broke it!
  • Tim Hill1 Level 1 Level 1 (35 points)
    I filed a bug with Apple ... can others who are seeing this do the same? The squeaky wheel and all that
  • xnav Level 5 Level 5 (6,635 points)
    Yep.
  • Austin Kinsella1 Level 6 Level 6 (11,520 points)
    Use a batch in Graphic Converter.

    AK
  • anonmill Level 1 Level 1 (0 points)
    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
  • red_menace Level 6 Level 6 (14,900 points)
    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).
  • Pierre L. Level 5 Level 5 (4,140 points)
    Looks like the Preview "Change Type of Images" is perfect.


    So why not just make a little AppleScript droplet that would have Preview.app do the job. It seems to be just a few GUI scripting steps away.
  • hungryjoe Level 2 Level 2 (250 points)
    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
  • twtwtw Level 5 Level 5 (4,900 points)
    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
  • Pierre L. Level 5 Level 5 (4,140 points)
    You're right, that's much simpler and faster.
  • anonmill Level 1 Level 1 (0 points)
    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.....
  • Tim Hill1 Level 1 Level 1 (35 points)
    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
  • p0lar Level 1 Level 1 (0 points)
    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
Previous 1 2 Next