コード例 #1
0
        /// <summary>
        /// creates a new CmsResource object from an image file
        /// </summary>
        /// <param name="imageFilename"></param>
        /// <returns></returns>
        public static CmsLocalImageOnDisk CreateFomImageFile(string imageFilename)
        {
            CmsLocalImageOnDisk ret = new CmsLocalImageOnDisk();

            ret.FileName      = Path.GetFileName(imageFilename);
            ret.FilePath      = imageFilename;
            ret.FileDirectory = Path.GetDirectoryName(imageFilename);
            ret.MimeType      = PageUtils.MimeTypeLookup(Path.GetExtension(imageFilename));

            if (File.Exists(imageFilename))
            {
                FileInfo fi = new FileInfo(imageFilename);

                ret.FileSize      = fi.Length;
                ret.FileTimestamp = fi.LastWriteTime;

                MetaDataItem[] metaData = MetaDataUtils.GetFromImageFile(imageFilename);
                ret.MetaData = CmsLocalFileOnDiskMetaItem.FromMetaDataItems(ret, metaData);
            }

            return(ret);
        } // CreateFromImageFile
コード例 #2
0
        /// <summary>
        /// creates a new CmsResource object from an Adobe file (is PDF, PSD, AI)
        /// </summary>
        /// <param name="imageFilename"></param>
        /// <returns></returns>
        public static CmsLocalFileOnDisk CreateFomAdobeDocument(string adobeFilename)
        {
            CmsLocalFileOnDisk ret = new CmsLocalFileOnDisk();

            ret.filename      = Path.GetFileName(adobeFilename);
            ret.filepath      = adobeFilename;
            ret.fileDirectory = Path.GetDirectoryName(adobeFilename);
            ret.MimeType      = PageUtils.MimeTypeLookup(Path.GetExtension(adobeFilename));

            if (File.Exists(adobeFilename))
            {
                FileInfo fi = new FileInfo(adobeFilename);


                ret.FileSize      = fi.Length;
                ret.FileTimestamp = fi.LastWriteTime;

                MetaDataItem[] metaData = MetaDataUtils.GetXmpData(adobeFilename);
                ret.MetaData = CmsLocalFileOnDiskMetaItem.FromMetaDataItems(ret, metaData);
            }

            return(ret);
        }
コード例 #3
0
        public static CmsLocalFileOnDisk CreateFromFile(string filenameOnDisk)
        {
            CmsLocalFileOnDisk ret = new CmsLocalFileOnDisk();

            ret.filename      = Path.GetFileName(filenameOnDisk);
            ret.filepath      = filenameOnDisk;
            ret.fileDirectory = Path.GetDirectoryName(filenameOnDisk);
            ret.MimeType      = PageUtils.MimeTypeLookup(Path.GetExtension(filenameOnDisk));

            if (File.Exists(filenameOnDisk))
            {
                FileInfo fi = new FileInfo(filenameOnDisk);


                ret.FileSize      = fi.Length;
                ret.FileTimestamp = fi.LastWriteTime;

                MetaDataItem[] metaData = new MetaDataItem[0];
                if (MetaDataUtils.CanExtractImageMetaData(filenameOnDisk))
                {
                    metaData = MetaDataUtils.GetFromImageFile(filenameOnDisk);
                }
                else if (MetaDataUtils.CanExtractOLEMetaData(filenameOnDisk))
                {
                    metaData = MetaDataUtils.GetFromOLEDocument(filenameOnDisk);
                }
                else if (MetaDataUtils.CanExtractXmpData(filenameOnDisk))
                {
                    metaData = MetaDataUtils.GetXmpData(filenameOnDisk);
                }

                ret.MetaData = CmsLocalFileOnDiskMetaItem.FromMetaDataItems(ret, metaData);
            }

            return(ret);
        }