# Overlay Image not scaling

**URL:** <https://community.wowza.com/t/overlay-image-not-scaling/46022>\
**Category:** Wowza Streaming Engine\
**Created:** [October 23, 2015, 3:51am UTC](https://community.wowza.com/t/overlay-image-not-scaling/46022 "2015-10-23T03:51:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ali\_hassan](https://avatars.discourse-cdn.com/v4/letter/a/3be4f8/32.png) [@ali\_hassan](https://community.wowza.com/u/ali_hassan)\
**Post date:** [October 23, 2015, 3:51am UTC](https://community.wowza.com/t/overlay-image-not-scaling/46022/1 "2015-10-23T03:51:35Z")

</div>

[https://www.wowza.com/docs/how-to-add-graphic-overlays-to-live-streams-with-wowza-transcoder](https://www.wowza.com/docs/how-to-add-graphic-overlays-to-live-streams-with-wowza-transcoder)

Developed wowza module to add overlay in live streaming using above link. Overlay images added into live stream but id didn’t scaled properly.

if (!encoderInfo.destinationVideo.isPassThrough())

{

int destinationHeight = encoderInfo.destinationVideo.getFrameSizeHeight();

scalingFactor = (double)destinationHeight/(double)sourceHeight;

System.out.println(“desination height”+destinationHeight);

System.out.println(“source height”+sourceHeight);

System.out.println(“scaling factor”+scalingFactor);

TranscoderVideoOverlayFrame overlay = new TranscoderVideoOverlayFrame(mainImage.GetWidth(scalingFactor),

mainImage.GetHeight(scalingFactor), mainImage.GetBuffer(scalingFactor));

overlay.setDstX(mainImage.GetxPos(scalingFactor));

overlay.setDstY(mainImage.GetyPos(scalingFactor));

encoderInfo.destinationVideo.addOverlay(overlayIndex, overlay);

//Add padding to the destination video i.e. pinch

encoderInfo.videoPadding[0] = 0; // left

encoderInfo.videoPadding[1] = 0; // top

encoderInfo.videoPadding[2] = 0; // right

encoderInfo.videoPadding[3] = (int)(((double)videoBottomPadding.getStepValue())\*scalingFactor); // bottom

encoderInfo.destinationVideo.setPadding(encoderInfo.videoPadding);

}

For scaling above code is used. I tried to print out destination and source height and scaling factor. Scalling factor changes with respect to stream.

But overlay image size remaing same for all streams. But if i add overlay via wowza manager and then view in different stream. Overlay image scaled correctly.

---

<div class="post-metadata">

**Author:** ![Jason\_Hilton](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/jason_hilton/32/437_2.png) [@Jason\_Hilton](https://community.wowza.com/u/Jason_Hilton)\
**Post date:** [November 5, 2015, 2:58pm UTC](https://community.wowza.com/t/overlay-image-not-scaling/46022/2 "2015-11-05T14:58:08Z")

</div>

Hi,

For details on overlays and the effects of adding them to the Encode or Decode sections of the transcoding template, please see [Transcoder overlay image requirements](https://www.wowza.com/docs/transcoder-overlay-image-requirements)

Jason

---

<div class="post-metadata">

**Author:** ![Zoran](https://sea2.discourse-cdn.com/flex002/user_avatar/community.wowza.com/zoran/32/385_2.png) [@Zoran](https://community.wowza.com/u/Zoran)\
**Post date:** [November 4, 2015, 5:30pm UTC](https://community.wowza.com/t/overlay-image-not-scaling/46022/3 "2015-11-04T17:30:51Z")

</div>

Hello,

If you want to have the overlay image displayed and scaled on all your transcoded outputs, you should add it when decoding the incoming stream.

The overlay can be added during the decode or during the encode.

I assume that using the Wowza Streaming Engine Manager UI you have added the overlay image in the decoding preset tab.

Zoran
