none
Image sizes for InlineShape RRS feed

  • Question

  • I've been working with images in Word 2010 lately, and have noticed when trying to get the original size of the image, as an InlineShape, that the numbers are misleading or wrong. E.g. when using a 1024x768, 96dpi image (one of those included with Windows by default in My Pictures), I might have the image resized (with the aspect ratio locked) to where Word reports the size as 281x210.75 (interesting as there are no partial pixels, I assume it is rounding up to 211 in reality) and a ScaleHeight and ScaleWidth of 37.0.

    281 is not 37% of 1024, and 210.75 is not 37% of 768. The scale at this resolution would be 27.44% for both height and width. However when I look at the size in Word's Layout dialog, it lists a height and width of 2.93"x3.9", which are 36.64% of the original 8"x10.67" image. So the properties are mismatched. Height and Width are in pixels, and ScaleHeight and ScaleWidth are for the size of the image as printed.

    Further, if I change the ScaleHeight to 100.0 (this seems equivalent to calling InlineShape.Reset()), the image does return to full size in the document (with part of it being cut off at the edge of the page), but the reported size is now 768x576. If you take this width as what will be displayed on the page as printed, since a portion is cut off, 768px is correct for the width, but 576 is not correct for the height as the entire height of the image is visible. The height would be 576 if the width of 768 was for the entire image. It is not, therefore I would expect a size of either 1024x768 or 768x768. For the record, if you want to replicate this, you should know I am using half-inch margins.

    I noticed that this question is somewhat related:

    https://social.msdn.microsoft.com/Forums/office/en-US/047c4ad4-d151-4dc8-af14-e934e651c6c6/how-to-get-the-original-image-information-form-a-inlineshape-object?forum=worddev

    This question's answer contains this information (which version of Word it's for is unclear): "The InlineShape class provides the Reset method which allows to remove any changes made to an inline shape (image in your case). Then you can read original properties." Unfortunately it doesn't match up with what I'm seeing.

    Is there any way to actually get the original size except saving it off into an image file and then checking? Or the correct current size?



    Wednesday, October 28, 2015 12:53 PM

All replies

  • Hi Christopher

    As this is not really a Developer/Programming question - "how does Word manage size information" - I think you'll have a better chance of reaching a wider public that might have some experience with it in an end-user forum. Possibly on TechNet.

    FWIW I suspect a number of factors are involved. The version of Word will certainly play a role. Some of the functionality probably comes from an earlier time, which might affect how size is being measured (pixels vs. inches). It may also have something to do with how Word inserts a graphics file. It may adjust dpi, which will affect size. And I know it adjusts size to fit the "container" (page margins or table cell, for example). All these could affect what Word considers the initial size.

    You can try checking the WordOpenXML underlying the document. That might be caching some information that's not available in the UI (which is what reflects to the object model). If yes, you can access that via the object model.


    Cindy Meister, Office Developer/Word MVP, <a href="http://blogs.msmvps.com/wordmeister"> my blog</a>

    Wednesday, October 28, 2015 6:28 PM
    Moderator