Search code examples
imagemagick

Extract/Convert an (multi-file)image that converted


I have a file made with a program , an image sticker maker . I know this program saves it's images(probably an image, a bg and a mask) into single file with extension ".adf" .

I couldn't convert the output file with image magick cause of below error :

convert: no decode delegate for this image format `output.adf' @ error/constitute.c/ReadImage/532.

I don't know how this Image converted with Image magick . it's my -list configure result :

Path: [built-in]

Name          Value
-------------------------------------------------------------------------------
NAME          ImageMagick

Path: configure.xml

Name          Value
-------------------------------------------------------------------------------
CC            vs10
COPYRIGHT     Copyright (C) 1999-2011 ImageMagick Studio LLC
DELEGATES     bzlib freetype jpeg jp2 lcms png tiff x11 xml wmf zlib
FEATURES      OpenMP
HOST          Windows
LIB_VERSION   0x671
LIB_VERSION_NUMBER 6,7,1,0
NAME          ImageMagick
RELEASE_DATE  2011-07-15
VERSION       6.7.1
WEBSITE       http:// www.image magick.org

I attached the file : src.adf

* EDIT * if I run file command on src.adf it tells :

root@MexHex-PC:# file -vv src.adf
file-5.25
magic file from /etc/magic:/usr/share/misc/magic

What's missed !? Thanks


Solution

  • This src.adf looks like a very minimal & flat data file. I know nothing about Dalahoo3D and/or ArcGis products, but we can quickly extract the embedded images with python.

    import struct
    
    with open('src.adf', 'rb') as f:
        # Calculate file size.
        f.seek(0, 2)
        total_bytes = f.tell()
        # Rewind to beging.
        f.seek(0)
        file_cursor = f.tell()
        image_cursor = 0
    
        while file_cursor < total_bytes:
            # Can for start of JPEG.
            if f.read(1) == b"\xFF":
                if f.read(3) == b"\xD8\xFF\xE0":
                    print("JPEG FOUND!")
                    # Backup and find the size of the image
                    f.seek(-8, 1)
                    payload_size = struct.unpack('<I', f.read(4))[0]
                    # Write image to disk
                    d_filename = 'image{0}.jpeg'.format(image_cursor)
                    with open(d_filename, 'wb') as d:
                        d.write(f.read(payload_size))
                    image_cursor += 1
                else:
                    f.seek(-3, 1)  # Back cursor up, and try again.
            file_cursor = f.tell()
    

    Which dumps the following three images...

    image0

    image1

    image2

    I'm sure this file was made with Imagemagick. I had already seen that one would convert the file to tiff image. He told me to do this with Imagemagick but did not explain the method.

    I'm guessing this is just a matter of miscommunication. It's true that ImageMagick commonly handles JPEG / TIFF formats, but not geographic information systems and/or 3D modeling. That's usually extended by a vendor -- like ArcGIS. I would bet that ImageMagick is present in the workflow of generating TIFF files, but .ADF wouldn't be supported by ImageMagick until someone writes a delegate coder.

    Update

    From this question, it looks like you'll need to extend ImageMagick delegates to call GDAL utilities. You'll need to update the delegates.xml file to call the correct utility.