IResourceLoadingCallback external vs embedded resources


We had an issue we external images timing out when converting from email messages to tif.

We were advised to use IResourceLoadingCallback to skip loading of the external images via

However we were under the impression this was for external resources only, using these options with embedded images is causing it to render images incorrectly. Is it possible to detect when a resource is external or embedded?

Attached is a test application we were using 17.11, I had to remove the aspose dlls due to the file size requirements here of 3k. (301.8 KB)

Also related to this case, is it possible to resize the images within the word document? We have a customer who is converting msg to tif and the output is unacceptable due to the image being cut off if it is too large.



Thanks for your inquiry.

Please use ResourceLoadingArgs.OriginalUri property to get the original URI of the resource as specified in imported document.

Please use the following ResizeLargeImage method to resize the big images according to page size. Hope this helps you.

Document _asposeDoc = new Document(reformattedStream, options);

foreach (Shape shape in _asposeDoc.GetChildNodes(NodeType.Shape, true))

Aspose.Words.Saving.ImageSaveOptions imageOptions = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Tiff);
imageOptions.ImageColorMode = Aspose.Words.Saving.ImageColorMode.None;
imageOptions.Resolution = 300;
imageOptions.TiffCompression = Aspose.Words.Saving.TiffCompression.Lzw;

_asposeDoc.Save(CurrentExecutingDirectory + output, imageOptions);

public static void ResizeLargeImage(Shape image)
    // Return if this shape is not an image.
    if (!image.HasImage)

    // Calculate the free space based on an inline or floating image. If inline we must take the page margins into account.
    PageSetup ps = image.ParentParagraph.ParentSection.PageSetup;
    double freePageWidth = image.IsInline ? ps.PageWidth - ps.LeftMargin - ps.RightMargin : ps.PageWidth;
    double freePageHeight = image.IsInline ? ps.PageHeight - ps.TopMargin - ps.BottomMargin : ps.PageHeight;

    ImageSize size = image.ImageData.ImageSize;
    Boolean exceedsMaxPageSize = size.WidthPoints > freePageWidth || size.HeightPoints > freePageHeight
        || image.Width > freePageWidth || image.Height > freePageHeight;

    if (exceedsMaxPageSize)
        // Calculate the ratio to fit the page size based on which side is longer.
        Boolean widthLonger = (size.WidthPoints > size.HeightPoints);
        double ratio = widthLonger ? freePageWidth / size.WidthPoints : freePageHeight / size.HeightPoints;

        // Set the new size.
        image.Width = size.WidthPoints * .30;
        image.Height = size.HeightPoints * .30;