Ejemplo n.º 1
0
        /// TODO:
        /// By ??
        /// Edited: Julian Nguyen(4/28/13)
        /// <summary>
        /// This will make a Thumbnail for the image.  
        /// </summary>
        /// <param name="source"></param>
        /// <param name="filename"></param>
        /// <param name="size"></param>
        /// <returns>The full Thumb Path.</returns>
        private string regenerateThumbnail(string source, string filename, int size)
        {
            Imazen.LightResize.ResizeJob resizeJob = new Imazen.LightResize.ResizeJob();
            string thumbSubDir = String.Empty;
            string fullThumbPath = String.Empty;

            // Which sub directory of thumbs_db to put this in...
            if (size == Settings.lrgThumbSize)
            {
                thumbSubDir = Settings.lrgThumbDir;
            }

            // Specifies a maximum height resolution constraint to scale the image down to
            resizeJob.Height = size;
            resizeJob.Width = size;
            resizeJob.Mode = Imazen.LightResize.FitMode.Crop;

            //get the full path
            fullThumbPath = System.IO.Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
                Settings.OrgName,
                Settings.PhotoLibraryName,
                Settings.PhotoLibraryThumbsDir,
                thumbSubDir,
                filename);

            if (File.Exists(source))
            {
                // Actually processes the image, copying it to the new location, should go in a try/catch for IO
                // One of Build's overloads allows you to use file streams instead of filepaths.
                // If images have to be resized on-the-fly instead of stored, that may work as well.
                try
                {
                    resizeJob.Build(
                        source,
                        fullThumbPath,
                        Imazen.LightResize.JobOptions.CreateParentDirectory
                    );
                }
                catch (IOException)
                {
                    return String.Empty;
                }

                return fullThumbPath;
            }
            else
            {
                return String.Empty;
            }
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------
        //By: Ryan Moe
        //Edited Last:
        //copies a picture into our picture library.
        //DOES NOT CHECK picturePath or picName, please do before hand.
        private String util_copyPicToLibrary(ErrorReport errorReport, String picturePath, String picNameInLibrary)
        {
            //check if file exists first!!!
            //if the picture does NOT exist.
            if (!File.Exists(picturePath))
            {
                errorReport.reportID = ErrorReport.FAILURE;
                errorReport.description = "Can't find the new picture to import to the library.";
                return "";
            }

            //check if the library is ok.
            if (!util_checkLibraryDirectory())
            {
                errorReport.reportID = ErrorReport.FAILURE;
                errorReport.description = "Something is wrong with the photo library.";
                return "";
            }

            //make the full picture path.
            String newPath = System.IO.Path.Combine(libraryPath, picNameInLibrary);

            // I haven't thought much about whether or not this is the right place to put this
            Imazen.LightResize.ResizeJob resizeJob = new Imazen.LightResize.ResizeJob();
            // specifies a maximum height resolution constraint
            resizeJob.Height = 120;
            // Actually processes the image, copying it to the new location, should go in a try/catch for IO
            // One of Build's overloads allows you to use file streams instead of filepaths.
            // If images have to be resized on-the-fly instead of stored, that may work as well.
            resizeJob.Build(
                picturePath,
                System.IO.Path.Combine(
                    libraryPath,
                    Properties.Settings.Default.PhotoLibraryThumbsDir,
                    picNameInLibrary),
                Imazen.LightResize.JobOptions.CreateParentDirectory
            );

            try
            {
                //copy the photo to the library.
                System.IO.File.Copy(picturePath, newPath, true);
            }
            catch
            {
                errorReport.reportID = ErrorReport.FAILURE;
                errorReport.description = "Unable to make a copy of the photo in the library.";
                return "";
            }

            //new library path
            return newPath;
        }
Ejemplo n.º 3
0
        //---------------------------------------------------------------------------
        /// By: Bill Sanders
        /// Edited Julian Nguyen(5/1/13)
        /// <summary>
        /// Generates a thumbnail for a specified image file and places it in an appropriate sub directory
        /// </summary>
        /// <param name="error"></param>
        /// <param name="srcPath"></param>
        /// <param name="picFileName"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        private String util_generateThumbnail(ErrorReport error, string srcPath, string picFileName, int size)
        {
            if ((srcPath == string.Empty) || (picFileName == string.Empty) || !File.Exists(srcPath))
            {
                setErrorReportToFAILURE("Unable to generate thumbnail, bad path or filename.", ref error);
                return String.Empty;
            }
            // I haven't thought much about whether or not this is the right place to put this
            Imazen.LightResize.ResizeJob resizeJob = new Imazen.LightResize.ResizeJob();
            string thumbSubDir = String.Empty;
            string fullThumbPath = String.Empty;

            // Which sub directory of thumbs_db to put this in...
            if (size == Settings.lrgThumbSize)
            {
                thumbSubDir = Settings.lrgThumbDir;
            }

            // Specifies a maximum height resolution constraint to scale the image down to
            resizeJob.Height = size;
            resizeJob.Width = size;
            resizeJob.Mode = Imazen.LightResize.FitMode.Crop;

            //get the full path
            fullThumbPath = System.IO.Path.Combine(_imagelibraryDirPath, Settings.PhotoLibraryThumbsDir, thumbSubDir, picFileName);

            // Actually processes the image, copying it to the new location, should go in a try/catch for IO
            // One of Build's overloads allows you to use file streams instead of filepaths.
            // If images have to be resized on-the-fly instead of stored, that may work as well.
            resizeJob.Build(
                srcPath,
                fullThumbPath,
                Imazen.LightResize.JobOptions.CreateParentDirectory
            );

            return fullThumbPath;
        }