/// <summary>
        /// Extracts binaries from the template and adds them to the package for processing.
        /// </summary>
        /// <param name="output"></param>
        /// <param name="engine"></param>
        /// <param name="package"></param>
        /// <returns></returns>
        private string ExtractBinaries(string output, Engine engine, Package package)
        {
            IExtractBinariesContentWrapper contentWrapper = new ExtractBinariesFromText(output);

            foreach (LinkReferenceWrapper linkAttribute in contentWrapper.GetLinkAttributes())
            {
                string pathAttributeValue = contentWrapper.GetAttributeValue(linkAttribute);
                // _logger.Debug("Path: " + pathAttributeValue);
                TcmUri targetItemUri = null;
                if (TcmUri.IsValid(pathAttributeValue))
                {
                    // Attribute value is TCM URI, now localize to currect context publication.
                    targetItemUri = engine.LocalizeUri(new TcmUri(pathAttributeValue));
                }

                if (targetItemUri != null || pathAttributeValue.StartsWith("/webdav/"))
                {
                    Component targetItem = engine.GetObject(targetItemUri ?? pathAttributeValue) as Component;
                    if (targetItemUri == null && targetItem != null)
                    {
                        targetItemUri = engine.LocalizeUri(targetItem.Id);
                    }

                    if ((targetItem != null) && (targetItem.ComponentType == ComponentType.Multimedia))
                    {
                        Item   binaryItem = package.CreateMultimediaItem(targetItemUri);
                        string itemName;
                        binaryItem.Properties.TryGetValue(Item.ItemPropertyFileName, out itemName);

                        Item existingItem = package.GetByName(itemName);
                        if (
                            existingItem == null ||
                            !existingItem.Properties[Item.ItemPropertyTcmUri].Equals(targetItemUri) ||
                            !existingItem.Equals(binaryItem) // Ensure that a transformed item is not considered the same
                            )
                        {
                            // _logger.Debug(string.Format("Image {0} ({1}) unique, adding to package", itemName, targetItemUri));
                            package.PushItem(itemName, binaryItem);
                        }
                        else
                        {
                            // _logger.Debug(string.Format("Image {0} ({1}) already present in package, not adding again", itemName, targetItemUri));
                        }

                        contentWrapper.ProcessLinkChange(linkAttribute, targetItemUri);
                    }
                }
            }

            return(contentWrapper.Content.ToString());
        }
        /// <summary>
        /// Extracts binaries from the template and adds them to the package for processing.
        /// </summary>
        /// <param name="output"></param>
        /// <param name="engine"></param>
        /// <param name="package"></param>
        /// <returns></returns>
        private string ExtractBinaries(string output, Engine engine, Package package)
        {
            IExtractBinariesContentWrapper contentWrapper = new ExtractBinariesFromText(output);
            foreach (LinkReferenceWrapper linkAttribute in contentWrapper.GetLinkAttributes())
            {
                string pathAttributeValue = contentWrapper.GetAttributeValue(linkAttribute);
                // _logger.Debug("Path: " + pathAttributeValue);
                TcmUri targetItemUri = null;
                if (TcmUri.IsValid(pathAttributeValue))
                {
                    // Attribute value is TCM URI, now localize to currect context publication.
                    targetItemUri = engine.LocalizeUri(new TcmUri(pathAttributeValue));
                }

                if (targetItemUri != null || pathAttributeValue.StartsWith("/webdav/"))
                {
                    Component targetItem = engine.GetObject(targetItemUri ?? pathAttributeValue) as Component;
                    if (targetItemUri == null && targetItem != null)
                    {
                        targetItemUri = engine.LocalizeUri(targetItem.Id);
                    }

                    if ((targetItem != null) && (targetItem.ComponentType == ComponentType.Multimedia))
                    {
                        Item binaryItem = package.CreateMultimediaItem(targetItemUri);
                        string itemName;
                        binaryItem.Properties.TryGetValue(Item.ItemPropertyFileName, out itemName);

                        Item existingItem = package.GetByName(itemName);
                        if (
                            existingItem == null ||
                            !existingItem.Properties[Item.ItemPropertyTcmUri].Equals(targetItemUri) ||
                            !existingItem.Equals(binaryItem) // Ensure that a transformed item is not considered the same
                        )
                        {
                            // _logger.Debug(string.Format("Image {0} ({1}) unique, adding to package", itemName, targetItemUri));
                            package.PushItem(itemName, binaryItem);
                        }
                        else
                        {
                            // _logger.Debug(string.Format("Image {0} ({1}) already present in package, not adding again", itemName, targetItemUri));
                        }

                        contentWrapper.ProcessLinkChange(linkAttribute, targetItemUri);
                    }
                }
            }

            return contentWrapper.Content.ToString();
        }