Digital Research/Atari .IMG images on the Mac

Discussion in 'Design and Graphics' started by macstatic, May 20, 2017.

  1. macstatic macrumors 65816

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #1
    What's the easiest (and hopefully free/low cost) way to view or convert .IMG image files (Atari GEM/Digital Research on the Mac?
    Graphic Converter works, but at US$ 40 is a bit costly for this only task.

    I expected XNview to do it (I think it handled it in the past), but for the Mac it's now called XNview MP (XNview is only for Windows) but if I'm not mistaken, both of them should handle over 500 formats including "Digital Research (GEMpaint) IMG" which is listed there), but it's not working for me.
    I also tried XNconvert, only to get an error message saying "XNconvert can't be opened, you should move it to the trash".

    Then I came across Recoil which is a Quicklook plugin. I installed it and reset Quicklook as instructed, but it still won't open IMG files by selecting them and pressing the spacebar. Perhaps something needs to be done in OSX in order to disassociate the IMG extension as a disk image (I would normally do a "Get info" on an IMG file, choose the application to open it by default in "Open with:" (followed by "Change all" if I want all IMG files to be opened by that app), but that only works with apps and not plugins as far as I know...).

    Suggestions?
     
  2. organicCPU macrumors 6502a

    organicCPU

    Joined:
    Aug 8, 2016
    #2
    XnConvert is working perfect for me and able to convert Atari sample IMG files. Try installing again and open the app by right click -> context menu -> open (to bypass gatekeeper) or try downloading from the Mac App Store https://itunes.apple.com/app/xnconvert/id436203431
     
  3. macstatic thread starter macrumors 65816

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #3
    The Mac app store version worked fine! I did the gatekeeper bypass thing, so there must have been something wrong with the file itself.

    Anyway, XnConvert works great!
    As a bonus, I got XnView MP to work as well. I had'nt quite understood how to use it, but messing around with its settings solved the problem and I was able to open and convert those image files. IMHO it's overly complicated though, and XnConvert will suffice for my basic use.
    Thanks for your suggestion for downloading from the App store and trying it out!
     
  4. macstatic thread starter macrumors 65816

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #4
    Is there a way I can just drag .IMG files over to the XnConvert icon and have it convert them to .PNG?
    The app's "Output" tab allows pre-configuring the format, output name etc. but it doesn't appear to be able to handle drag & drop from the OSX dock.
    Is the perhaps a simple way to allow this to be done by using an Automator action or Applescript?
     
  5. organicCPU macrumors 6502a

    organicCPU

    Joined:
    Aug 8, 2016
    #5
    If it's just for your private needs and not for commercial usage, then take a look at the Command Line utility nconvert from XnSoft, too. See http://www.xnview.com/en/nconvert/ . It's quite simple to write an AppleScript to drag and drop convert a file with it.
     
  6. macstatic thread starter macrumors 65816

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #6
    Thanks organicCPU!
    I tried it (the documentation is quite sketchy but you basically put the binary inside the /usr/local/bin/ folder which allows you to get "nconvert" as a new command in the OSX Terminal.
    Having changed directory (cd) to the one containing the IMG files I was able to convert them to PNG using the follow command:

    nconvert -out png -keepfiledate *.IMG *.Img *.img

    (apparently its input file extension is case sensitive so I would have to enter the various upper/lower case combinations of IMG). Also "-keepfiledate" turns out to work only on Windows platform according to the author. The converted file is supposed to end up with the same file date/time as the original one. Strangely this works fine in XNconvert!

    So how do I create an Applescript for this (so I can drag/drop one or several IMG files (or a folder with IMG files) to the script icon in the dock and also fix the "keep file date" issue?
     
  7. organicCPU macrumors 6502a

    organicCPU

    Joined:
    Aug 8, 2016
    #7
    An AppleScript like this would work for the basic task:
    Code:
    on open filenames
        repeat with fn in filenames
            set filename to POSIX path of fn
            do shell script "nconvert -out png '" & filename & "'"
        end repeat
    end open
    You are right, the -keepfiledate option doesn't work on macOS. Do you have Command Line Tools or Xcode installed?
     
  8. macstatic, May 28, 2017
    Last edited: May 28, 2017

    macstatic thread starter macrumors 65816

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #8
    Yes, I have Xcode installed. I assume you're referring to the "touch" command, right?

    A while back I worked on (and got a lot of help from various forums) a solution using EXIFtool in order to create a drag & drop script for adding EXIF information to scanned images (which don't have that info to start with), and another script for restoring the file creation date from the EXIF data (which Adobe Lightroom messes up and time-stamps with the current date whenever an image is edited). So I had to install Xcode (or was it the command line tools which IIRC was just a few commands and not the entire Xcode suite).
    Perhaps some of the code from that script can be used here as well?

    If I'm not mistaken, the section which I've colored in red is the part of the code which seems to read the time/date from the Exiftool "-DateTimeOriginal" tag which then uses the "touch -t" command to do the actual filename date change. I might be mistaken about the details as it's a while since I looked into that.

    # set Exiftool path
    export PATH="$PATH:/usr/local/bin"

    for f in "$@"
    do

    # write DateTimeOriginal EXIF date-tag if not present
    # exiftool -q -if '$dateTimeOriginal and substr($dateTimeOriginal,0,19) ne substr($MDItemFSCreationDate,0,19)' -aaa "$f"
    # compare DateTimeOriginal EXIF tag with file Creation date, overwrite file Creation date if different
    # update file Modification date of processed files
    if [ $? == 0 ]; then
    touch -t `exiftool -s -s -s -d "%Y%m%d%H%M.%S" -DateTimeOriginal "$f"` "$f" && touch "$f"
    fi

    done


    Maybe "touch -t" can be used in this script to read from the original IMG file's Creation Date, and use that to write the converted PNG file's Creation Date. Just me thinking out loud... :)
    UPDATE: I looked further into this and it appears the "stat" command can be used to display information about a file, so maybe it can be used to read eh date/time from the original file, then "touch -t" (together with the date/time just obtained) to write the PNG file's time/date. I don't understand the syntax though.


    By the way, the script you posted gave me an error message saying:
    sh: nconvert: command not found

    Nconvert is installed (I just tried it in the Terminal), but I seem to recall an issue I had with a script I was working on where I used the wrong quote character. I'll try to find out more...
     
  9. organicCPU, May 28, 2017
    Last edited: May 28, 2017

    organicCPU macrumors 6502a

    organicCPU

    Joined:
    Aug 8, 2016
    #9
    I understand! The nconvert can't be found. Use this script instead and maybe point nconvertpath to the correct location.
    Code:
    on open filenames
    set nconvertpath to "/usr/local/bin/nconvert"
        repeat with fn in filenames
            set filename to POSIX path of fn
            do shell script nconvertpath & " -out png '" & filename & "'"
        end repeat
    end open
    Anyway, I keep my command line binaries in a non standard place outside the local bin folder and therefore prefer to set a custom path to binaries.

    Your idea with the exif tag could lead to a solution, but only for files that will have EXIF-tags. The touch command has some limitations, that make it not my first choice. I haven't used stat command, but will take a look on it.

    My idea was the use of
    Code:
    GetFileInfo -d path/to/file.IMG
    GetFileInfo -m path/to/file.IMG
    to get the creation and modification date of the original file and use
    Code:
    SetFile -d path/to/file.png
    SetFile -m path/to/file.png
    to write the creation and modification date back to the written png

    Those commands are part of the Command Line Tools that can easily be installed from Xcode preferences, if they don't already exist on your system.

    What keeps me from posting an update to the AppleScript is the fact that GetFileInfo and SetFile are marked as deprecated as of Xcode 6. Those commands will break at some point of OS update. There are several solutions to deal with that, including to compile a custom binary for that functionality that hopefully won't break. As I'm not a programmer, that's a bit challenging for me. I'm not sure wether the use of plain C++ with NSURLCreationDateKey or the Cocoa route with NSFileManager is the better approach. Then there is still the question what would happen if Apple drops the HFS+ filesystem for APFS filesystem. So maybe the quick and dirty solution to use GetFileInfo and SetFile until they actually break would be better than fiddling around with a custom binary. Maybe a question for the programmer forum...

    Another thing that has to be done, is to consider that the nconvert command writes files with incremental numbers if the filename already exists, like filename_1.png, filename_2.png, etc.. The existence of such a file has to be checked to use the SetFile command on the right file. All the mentioned commands can either work in a single "do shell script" line or can be called from AppleScript one after one. Another thing to choose the best solution...

    I'll work on this a bit, but don't know, if I'll finally find a working solution that is satisfying enough.
     
  10. macstatic, May 28, 2017
    Last edited: May 28, 2017

    macstatic thread starter macrumors 65816

    Joined:
    Oct 21, 2005
    Location:
    Norway
    #10
    Yes!!! Your new script worked :)
    It handled drag & drop of one/multiple IMG files to the script's dock icon, but not drag & drop of a folder (which contained IMG files). Does the first line (on open filenames) need some modification to allow looking inside a folder as well?
    Also, it choked on dragging & dropping multiple file types. There should be some sort of filtering I suppose to not try to process non-recognized filetypes.

    Actually, there's a "-1" input filetype option in Nconvert according to the help-file, which means "automatic", but I haven't gotten it to work. Might be a syntax issue or something I've misunderstood. I'll get back to that if I figure it out, but it might be useful if any image type dragged to the script (perhaps except PNG) would be converted to PNG.
    ... or a script which only converts IMG files and leaves the rest alone. I haven't decided yet.



    Adding a full path is probably good practice regardless. Nice catch!

    That's true about the touch command having limitations. I can't remember the exact details but there was something about the touch command not being able to change a creation date if the source was before or after a specific date or something... a real hassle. I spent a lot of time figuring a workaround with that Exiftool script.


    Yes, I've got it too, so I probably installed the whole Xcode thing (which 99.9% of is left unused as I'm no programmer) :p
    I just looked into setfile myself before reading your reply! I found this, with some examples and with some experimentation I found the following to work which takes the file Creation date from a source file and replaces the destination file's Creation date with the same:

    SetFile -d "$(GetFileInfo -d SOURCE_FILE.IMG)" DESTINATION_FILE.PNG

    I tested this with the "source_file" being of both an earlier or later creation date than the destination file. Worked a whole lot better than touch ;)
    (on second thought, perhaps the modification date should be updated to "now" each time, so that it's possible to see when the filetype conversion took place).


    Oh, that's frustrating! This converting solution is something I'm working on for others as well, so it should be something which can be readily used.

    I think so. Since the target group for this script are regular computer users and not programmers, would there be a way to integrate the "nconvert" and "setfile" commands so that they don't have to download and install everything from scratch? Just to make it super-easy for people to use. It's a pity XnConvert doesn't just allow drag & drop of files to be converted.


    Many details to keep in mind. Thanks for looking into this!
     

Share This Page