Powerpoint Automation access to GIF and JPEG

T

Tim

Dear All,

I am currently using automation (of PowerPoint 2003) from C++ to process the
embedded objects within a PowerPoint presentation but I have run into a
difficulty with PowerPoint documents created before MS PowerPoint 2003 with
regard to GIF and JPEG embedded types.

When you embed an object from file, using the standard OLE dialog (Insert >
Object > Create From File), if that file happens to be a GIF or a JPEG in
PowerPoint 2003 it will store this as a Package type which I can quite
easily process and access the native format of the graphics files in
question.

The problem arises in previous versions of PowerPoint. In these instances
the object is embedded as its own compound document: when looking at the raw
data representation. I am assuming this object is used by MSPhotoEd.3 which
happens to be the registered server for these file types on my system? Does
anyone know how I can get to the native data of the GIF or JPEG in this
scenario?

I appreciate the crossover with the ole programming group but thought this
group was probably the most appropriate.

Thanks for any help on this.

Tim.
 
S

Steve Rindsberg

Dear All,

I am currently using automation (of PowerPoint 2003) from C++ to process the
embedded objects within a PowerPoint presentation but I have run into a
difficulty with PowerPoint documents created before MS PowerPoint 2003 with
regard to GIF and JPEG embedded types.

When you embed an object from file, using the standard OLE dialog (Insert >
Object > Create From File), if that file happens to be a GIF or a JPEG in
PowerPoint 2003 it will store this as a Package type which I can quite
easily process and access the native format of the graphics files in
question.

The problem arises in previous versions of PowerPoint. In these instances
the object is embedded as its own compound document: when looking at the raw
data representation. I am assuming this object is used by MSPhotoEd.3 which
happens to be the registered server for these file types on my system? Does
anyone know how I can get to the native data of the GIF or JPEG in this
scenario?

Are you using example files supplied you or are you creating your own tests
using earlier versions of PPT? If the former, are the images embedded OLE
shapes or are they embedded images (which'd be created via Insert, Picture,
From File)?
 
T

Tim

I am creating my own tests with all versions of PPT back to 97 and the
images are embedded as objects (OLE shapes) using the create from file
option of the insert object dialog and are not inserted using insert
picture.

This of course may not be representational because some of the OLE servers
for image formats such as this will be more modern than could be the case in
older existing PPTs and this could be a concern if they were to cause a
differing embedded format?

As I understand it when you insert it as a picture it will be converted into
a native picture format and is no longer an embedded object in the strictest
sense and for my purpose I am not concerned with this case.
 
S

Steve Rindsberg

I am creating my own tests with all versions of PPT back to 97 and the
images are embedded as objects (OLE shapes) using the create from file
option of the insert object dialog and are not inserted using insert
picture.

Thanks. That tosses out several distractions. Interestingly, when I do
Insert, Object, Create from File (even though I don't click As Icon) I get an
icon in PPT2003 when inserting PNG or JPG. See below ...
This of course may not be representational because some of the OLE servers
for image formats such as this will be more modern than could be the case in
older existing PPTs and this could be a concern if they were to cause a
differing embedded format?

I'm guessing too that the OLE server may differ depending on the file extension
and what app's registered as its "owner" on the system where it's inserted.
Apparently we're seeing the result of that in the difference between what you
see on your system and I on mine?

Hm. If you ungroup the OLE object, you'll get a WMF picture in which there's a
BMP embedded. Would that be sufficient?
As I understand it when you insert it as a picture it will be converted into
a native picture format and is no longer an embedded object in the strictest
sense and for my purpose I am not concerned with this case.

That's correct; when you insert a picture from file it doesn't come in as an
OLE embedded object.
 
T

Tim

Apologies for a slightly verbose reply...

In my instance I always get the icon representation when inserting any of
the three graphic formats I am interested in (GIF, JPEG and TIFF) into PPT
2003 regardless of whether the "As Icon" option is checked.

The problem I have is accessing the original data format and so I cannot
make do with any conversion. The reason I am doing this is to ensure only
certain graphic types are permitted to be embedded in the document and I
check this using custom binary signature analysis algorithms.

If I ungroup an embedded object inserted it simply converts whatever the
representation currently is into a native picture so destroying what it
originally was.

In PPT 2003 I have tested it on several versions of the OS (XP, 2000, 2003)
and I always get the same result - when I access the embedded object in its
raw data format (programmatically using the OLEClipboard and Automation) it
is always contained within a Package type (the CLSID indicates this) and so
I can get the actual original binary representation of the graphic image by
cracking open this package (it has a simple header within the IStream that
can simply be parsed). It appears this is to resolve the problem that I have
found on previous versions...

This is very different however to all other versions as I have inserted a
GIF into a PowerPoint97 document running on a vanilla XP install which has
MS Photo Editor (by virtue of Office 97 I believe?) as the handler for GIFs.
Indeed when I inspect the embedded object I can see that it has a ProgID of
MSPhotoEd.3. When I open that same document on my home XP system which has
Office 2003 and so no MS Photo Editor if I attempt to view the embedded GIF
I am informed that there is no handler available on my system to open the
object.

I am starting to believe I will not be able to access the original version
of the data as in these instances it is replaced by a MS Photo Editor
representation as it is the OLE server registered when installing the older
versions of office.

Thanks for all the help and comments so far.
 
S

Steve Rindsberg

Apologies for a slightly verbose reply...

None needed.
In my instance I always get the icon representation when inserting any of
the three graphic formats I am interested in (GIF, JPEG and TIFF) into PPT
2003 regardless of whether the "As Icon" option is checked.

Same here. Except on a system where MSPhotoEditor is installed. There, even
in PPT2003, inserting an object a) shows me an image and b) gives an OLEProgID
of MSPhotoEd.3

It almost seems that this is a bug. You'd expect PPT to respect the server app
registered to launch the image type and use that as the OLE server. It doesn't
and instead gives us just an icon.
The problem I have is accessing the original data format and so I cannot
make do with any conversion. The reason I am doing this is to ensure only
certain graphic types are permitted to be embedded in the document and I
check this using custom binary signature analysis algorithms.

OK. I can understand the need for this (and why ungrouping won't work).

I mostly work in VBA, so don't have any real way of getting at the OLE data,
but I wonder if that can be cracked apart to get at the image data within when
it's an MSPhotoEdit object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top