open xml how to set picture size

open xml how to set picture size

Open XML: A Complete Information to Setting Image Dimension

Introduction

Greetings, readers! Welcome to our in-depth information on methods to grasp image measurement adjustment in Open XML paperwork. Whether or not you are an skilled developer or simply beginning out, this text will offer you all of the information it is advisable to seamlessly resize photographs in your Open XML paperwork.

Understanding Image Dimension in Open XML

Open XML makes use of the DrawingML namespace to retailer and manipulate photographs. Throughout the DrawingML hierarchy, the <pic> aspect represents the image itself. To specify the scale of the image, you have to modify the width and peak attributes of the <pic> aspect. These attributes specify the width and peak of the image in factors (pt), the place 1 pt equals roughly 1/72 inch.

Setting Image Dimension Programmatically

You may programmatically set the image measurement in Open XML utilizing varied strategies. Listed below are two fashionable approaches:

Utilizing the Open XML SDK

The Open XML SDK offers a complete set of courses for working with Open XML paperwork. To set image measurement utilizing the SDK, comply with these steps:

  1. Open the doc and find the <pic> aspect representing the image you need to resize.
  2. Entry the Width and Peak properties of the <pic> aspect.
  3. Set the width and peak values in factors.

Utilizing Open XML Productiveness Instrument

When you’re comfy working with XML, you possibly can straight modify the Open XML markup to set image measurement. Open the doc in an XML editor and find the <pic> aspect. Throughout the <pic> aspect, modify the width and peak attributes with the specified values.

Desk: Frequent Image Sizes

Image Dimension (pt) Pixel Dimension (px) Decision (dpi)
150 x 150 150 x 150 72
300 x 300 300 x 300 72
600 x 600 600 x 600 72
1200 x 1200 1200 x 1200 72
2400 x 2400 2400 x 2400 72

Sustaining Side Ratio

When resizing photos, it is usually necessary to keep up the unique facet ratio to keep away from distortion. To do that, you should use the scale attribute of the <pic> aspect. By setting scale to 1, the image is scaled proportionally, preserving its facet ratio.

Conclusion

Congratulations, readers! You now have an intensive understanding of methods to set image measurement in Open XML paperwork. Whether or not you select to make use of the Open XML SDK or modify the XML markup straight, the methods outlined on this article will empower you to exactly management the looks of photographs in your paperwork.

Discover different articles on our web site to additional improve your Open XML information. Joyful coding!

FAQ about Open XML – Easy methods to set image measurement

How do I set the peak of an image?

The peak of an image may be set utilizing the peak attribute of the <pic:blipFill> aspect. The worth of the peak attribute is laid out in English Metric Items (EMU), the place 1 EMU is the same as 0.001 inch. For instance, to set the peak of an image to 1 inch, you’ll use the next code:

<pic:blipFill>
    <a:blip r:embed="rId2"/>
    <a:stretch>
        <a:fillRect/>
        <a:stretchProp>
            <a:fillRect/>
            <a:stretchProp val="1000000"/>
        </a:stretchProp>
    </a:stretch>
</pic:blipFill>

How do I set the width of an image?

The width of an image may be set utilizing the width attribute of the <pic:blipFill> aspect. The worth of the width attribute is laid out in English Metric Items (EMU), the place 1 EMU is the same as 0.001 inch. For instance, to set the width of an image to 1 inch, you’ll use the next code:

<pic:blipFill>
    <a:blip r:embed="rId2"/>
    <a:stretch>
        <a:fillRect/>
        <a:stretchProp>
            <a:fillRect/>
            <a:stretchProp val="1000000"/>
        </a:stretchProp>
    </a:stretch>
</pic:blipFill>

How do I set the facet ratio of an image?

The facet ratio of an image may be set utilizing the lockAspectRatio attribute of the <pic:stretch> aspect. When the lockAspectRatio attribute is ready to true, the facet ratio of the image will likely be maintained when the image is resized. For instance, to set the facet ratio of an image to 16:9, you’ll use the next code:

<pic:blipFill>
    <a:blip r:embed="rId2"/>
    <a:stretch>
        <a:fillRect/>
        <a:stretchProp>
            <a:fillRect/>
            <a:stretchProp val="1000000"/>
        </a:stretchProp>
    </a:stretch>
    <a:lockAspectRatio val="true"/>
</pic:blipFill>

How do I crop an image?

An image may be cropped utilizing the cropLeft, cropTop, cropRight, and cropBottom attributes of the <pic:crop> aspect. The values of those attributes are laid out in English Metric Items (EMU), the place 1 EMU is the same as 0.001 inch. For instance, to crop an image from the left by 1 inch, you’ll use the next code:

<pic:blipFill>
    <a:blip r:embed="rId2"/>
    <a:stretch>
        <a:fillRect/>
        <a:stretchProp>
            <a:fillRect/>
            <a:stretchProp val="1000000"/>
        </a:stretchProp>
    </a:stretch>
    <pic:crop>
        <pic:cropLeft val="100000"/>
        <pic:cropTop val="0"/>
        <pic:cropRight val="0"/>
        <pic:cropBottom val="0"/>
    </pic:crop>
</pic:blipFill>

How do I rotate an image?

An image may be rotated utilizing the rotation attribute of the <pic:blipFill> aspect. The worth of the rotation attribute is laid out in levels. For instance, to rotate an image by 90 levels, you’ll use the next code:

<pic:blipFill>
    <a:blip r:embed="rId2"/>
    <a:stretch>
        <a:fillRect/>
        <a:stretchProp>
            <a:fillRect/>
            <a:stretchProp val="1000000"/>
        </a:stretchProp>
    </a:stretch>
    <a:rotation val="900000"/>
</pic:blipFill>

How do I flip an image?

An image may be flipped utilizing the flipH and flipV attributes of the <pic:blipFill> aspect. The worth of the flipH attribute is ready to true to flip the image horizontally, and the worth of the flipV attribute is ready to true to flip the image vertically. For instance, to flip an image horizontally, you’ll use the next code:

<pic:blipFill>
    <a:blip r:embed="rId2"/>
    <a:stretch>
        <a:fillRect/>
        <a:stretchProp>
            <a:fillRect/>
            <a:stretchProp val="1000000"/>
        </a:stretchProp>
    </a:stretch>
    <a:flipH val="true"/>
</pic:blipFill>

How do I set the transparency of an image?

The transparency of an image may be set utilizing the alpha attribute of the <pic:blipFill> aspect. The worth of the alpha attribute is specified as a proportion, the place 0% is totally clear and 100% is totally opaque. For instance, to set the transparency of an image to 50%, you’ll use the next code:

<pic:blipFill>
    <a:blip r:embed="rId2"/>
    <a:stretch>
        <a:fillRect/>
        <a:stretchProp>
            <a:fillRect/>
            <a:stretchProp val="1000000"/>
        </a:stretchProp>
    </a:stretch>
    <a:alpha val="50000"/>
</pic:blipFill>

How do I add a border to an image?

A border may be added to an image utilizing the <pic:border> aspect. The <pic:border> aspect has a number of attributes that can be utilized to customise the looks of the border, together with the coloration, width, and dashStyle attributes. For instance, so as to add a 1-point black border to an image, you’ll use the next code:

<pic:blipFill>
    <a:blip r:embed="rId2"/>
    <a:stretch>
        <a:fillRect/>
        <a:stretchProp>
            <a:fillRect/>
            <a:stretchProp val="1000000"/>
        </a:stretchProp>
    </a:stretch>
</pic:blipFill>
<pic:border>
    <pic:coloration rgb="FF000000"/>
    <pic:width val="12700"/>
    <pic:dashStyle val="stable"/>
</pic:border>

How do I group photos?

Footage may be grouped collectively utilizing the <pic:grpSp> aspect. The <pic:grpSp> aspect can comprise a number of <pic:pic> parts, and the images within the group may be organized utilizing the x and y attributes of the <pic:pic> parts. For instance, to group two photos collectively and prepare them facet by facet, you’ll use the next code:

<pic:grpSp>
    <pic:cNvPr id="1" identify="Group 1" descr="Group of two photos"/>
    <pic:cNvGrpSp>
        <a:xfrm>
            <a:off x="0" y="0"/>
            <a:ext cx="0" cy="0"/>
        </a:xfrm>
    </pic:cNvGrpSp>
    <pic:pic>
        <pic:nvPicPr>
            <pic:cNvPr id="2" identify="Image 1" descr=""/>
            <pic:cNvPicPr/>
        </pic:nvPicPr>
        <pic:blipFill>
            <a:blip r:embed="rId2"/>
            <a:stretch>
                <a:fillRect/>
            </a:stretch>
        </pic:blipFill>
        <pic:spPr>
            <a:xfrm>
                <a:off x="0" y="0"/>
                <a:ext cx="0" cy="0"/>
            </a:xfrm>
        </pic:spPr>
    </pic>
    <pic:pic>
        <pic: