private string SaveFile(string uploadDir, byte[] decodedArray, PictureMetaDataAttribute metaData, string fileName)
    {
        string path = Server.MapPath(Web.Attachments);

        FileSystem.CreateFolder(path + uploadDir);
        string file;

        if (string.IsNullOrEmpty(fileName))
        {
            file = uploadDir + "\\" + Guid.NewGuid() + ".png";
        }
        else
        {
            file = FileSystem.GetUniqueAttachmentFilename(uploadDir, fileName);
            //fileName = System.Text.RegularExpressions.Regex.Replace(fileName, @"\s+", "-");//remove white space //MN 20150226 replaced with GetUniqueAttachmentFilename
            //fileName = fileName.LeftUntilLast(".") + ".png"
        }

        //string file = uploadDir + "\\" + fileName;  //MN 20150226 replaced with GetUniqueAttachmentFilename
        var stream = new MemoryStream(decodedArray);

        if (metaData == null)
        {
            // save temp file, full size, we will process this later using UpdateFromRequest ActiveRecord MetaData (in hidden field "paste_")
            stream.SaveStreamToFile(path + file);
        }
        else
        {
            // for rich text edit pasting - we are not using UpdateFromRequest ActiveRecord MetaData so this is the final processing
            //stream.SaveStreamToFile(path + file);
            ImageProcessing.ResizeImageUsingMetaData(file, metaData, stream, "image/png");
        }
        file = file.Replace("\\", "/");
        return(file);
    }
Beispiel #2
0
        // You can put any business logic associated with this entity here


        public PictureMetaDataAttribute GetMetaData()
        {
            var meta = new PictureMetaDataAttribute();

            meta = new DefaultPictureMetaData();


            return(meta);
        }
Beispiel #3
0
        public static PictureMetaDataAttribute GetMetaData()
        {
            var metaData = new PictureMetaDataAttribute();

            metaData.IsExact            = true;
            metaData.IsCropped          = true;
            metaData.IsThumbnailExact   = true;
            metaData.IsThumbnailCropped = true;
            metaData.Width            = 180;
            metaData.Height           = 180;
            metaData.ThumbnailWidth   = 75;
            metaData.ThumbnailHeight  = 75;
            metaData.PreviewWidth     = 40;
            metaData.PreviewHeight    = 40;
            metaData.IsPreviewCropped = true;
            //metaData.UseSubfolder = false;
            //metaData.Subfolder = "mike";
            return(metaData);
        }
Beispiel #4
0
        public static PictureMetaDataAttribute GetMetaData()
        {
            var metaData = new PictureMetaDataAttribute();

            metaData.IsExact            = false;
            metaData.IsCropped          = false;
            metaData.Width              = 1000;
            metaData.Height             = 1000;
            metaData.DontResizeOriginal = true;

            metaData.ZoomWidth     = 1000;
            metaData.ZoomHeight    = 1000;
            metaData.IsZoomCropped = true;
            metaData.IsZoomExact   = true;

            metaData.BigWidth     = 800;
            metaData.BigHeight    = 800;
            metaData.IsBigCropped = true;
            metaData.IsBigExact   = true;

            metaData.SmallWidth     = 400;
            metaData.SmallHeight    = 400;
            metaData.IsSmallCropped = true;
            metaData.IsSmallExact   = true;

            metaData.ThumbnailWidth     = 200;
            metaData.ThumbnailHeight    = 200;
            metaData.IsThumbnailCropped = true;
            metaData.IsThumbnailExact   = true;

            metaData.PreviewWidth     = 40;
            metaData.PreviewHeight    = 40;
            metaData.IsPreviewCropped = false;
            metaData.IsPreviewExact   = false;
            //metaData.UseSubfolder = false;
            //metaData.Subfolder = "mike";
            return(metaData);
        }