EMF image embedded in a PowerPoint file on OS X

Someone sent me a Microsoft PowerPoint presentation to review. The file I received was a .pptx file which I opened using the PowerPoint application in Microsoft Office 2016 for Mac on my MacBook Pro laptop running OS X El Capitan (10.11.6). When I viewed the presentation, I noticed one of the slides was blank. I sometimes receive Microsoft Excel workbooks which contain a worksheet that should normally contain network diagrams where the diagrams don't appear when viewed on my Mac laptop, but do appear when I open the file in Microsoft Excel on a system running the Microsoft Windows operating system. In such cases, I've found that since the .xlsx or .xlsm file format is just an XML-based container format akin to a zip file, I rename the files where the problem occurs to have a .zip rather than .xlsx or .xlsm extension, which then allows me to extract the files contained within the file - see Zipping and unzipping Excel xlsx files and Extracting embedded documents from an Excel .xlsm file. Then I use the OS X file command in a Terminal window to examine the .bin files in the xl/embeddings subdirectory that is produced when I extract the files and folders from the zip file. That utility tells me which of the .bin files represent embedded Microsoft Visio or PowerPoint files, so I can then give the Visio ones a .vsd extension rather than a .bin extension. I can then view the diagrams with the free VSD Viewer Pro application I have on the Mac. Since there are usually several .bin files in the directory, I created a Python script to determine the file type for all of the files in a directory at once.

So I thought that a similar issue might have resulted in the blank slide appearing when I viewed the diagram on my Mac. Since I have Apache OpenOffice and LibreOffice, two free and open-source software suites that can read files created with Microsoft Office, on my Mac, I opened the .pptx file in those applications. The diagram appeared in both applications, but was garbled in both packages, though LibreOffice rendered the diagram fairly well, much better than OpenOffice. I also tried viewing the .pptx file in the OS X Preview image viewer application. Interestingly, Preview showed the diagram in the thumbnail view at the left side of the Preview window when I opened the file, but only a blank slide in the list of slides. When I opened the file with PowerPoint 2016 on my Windows 10 desktop system, the diagram was visible and looked fine and appeared to be the same diagram as I saw on the immediately preceding slide, slide 20. When I mentioned the issue to the person who would be giving the presentation, he told me he was aware that the Visio diagram didn't appear on slide 21 on Mac systems, so the person who produced the file had inserted a JPEG version of the diagram on slide 20.

Since PPTX files are also zipped, XML-based files, I tried a similar technique with the .pptx file that I've been using with the Excel .xlsx and .xlsm files. I used the Finder to duplicate the file, renamed the duplicate to have a .zip rather than a .pptx extension and then unzipped the file. I could then see 10 image files from the .pptx file, including one named image7.jpg, which was the image on slide 20. The image on slide 21 was named image8.emf. Enhanced Metafile (EMF) files are Windows Graphic Device Interface (GDI) files, which aren’t supported with the default software on OS X. I couldn’t find any way to view the EMF file with the built-in software that is a standard part of OS X.

I was able to convert the EMF file to a Portable Network Graphics (PNG) file using LibreOffice. To do so, you can use the soffice program found in the /Applications/LibreOffice.app/Contents/MacOS/ directory, if LibreOffice is installed on the system. Use the --headless and --convert-to arguments to the program as shown below.

$ /Applications/LibreOffice.app/Contents/MacOS/soffice  --headless --convert-to png image8.emf
convert /Users/jdoe/Documents/image8.emf -> /Users/jdoe/Documents/image8.png using filter : draw_png_Export
$ ls -lg image8.*
-rwxr-xr-x@ 1 ABC\Domain Users  1134052 Nov 20 20:37 image8.emf
-rw-r--r--  1 ABC\Domain Users   174461 Nov 20 20:42 image8.png

When I opened the .png file that was created by the program, it appeared as the diagram appeared in LibreOffice. I.e., most of the diagram was readable, but the text on some of the objects on the diagram was somewhat garbled.

Related articles:

  1. Zipping and unzipping Excel xlsx files
  2. Extracting embedded documents from an Excel .xlsm file
  3. VSD Viewer Pro 1.2
  4. Determining a file's type from within a Python script