예제 #1
0
        public IHttpActionResult Post(ConvertBindModel model)
        {
            try
            {
                if (model == null)
                {
                    return(BadRequest("Model can not be null. Please fill up the model data."));
                }

                ImageProcess.Converter.Convert convert = new ImageProcess.Converter.Convert(model.srcPath, model.destPath, model.type);
                convert.Execute();
                return(Created(model.destPath, model));
            }

            catch (MyFileNotFoundException)
            {
                return(BadRequest("File with path  " + model.srcPath + " not found."));
            }
            catch (SourceAndDestPathException)
            {
                return(BadRequest("Source or Destination path is an empty string, null or contains invalid characters."));
            }
            catch (UnsupportedDestPathException)
            {
                return(BadRequest("Destination path " + model.destPath + " is in an invalid format."));
            }
            catch (MyOutOfMemoryException)
            {
                return(BadRequest("There is not enough memory to continue the execution of a program"));
            }
            catch (MySystemException)
            {
                return(BadRequest("There is a problem with source path or destionation path."));
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: FMI-VT/API
        private void button2_Click(object sender, EventArgs e)
        {
            String imageLocation = "";

            try
            {
                SaveFileDialog dialog = new SaveFileDialog();

                DialogResult dr = dialog.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    imageLocation             = dialog.FileName;
                    pictureBox1.ImageLocation = imageLocation;
                    label5.Text = imageLocation + comboBox2.SelectedItem;
                }
            }
            catch
            {
            }

            ImageProcess.Converter.Convert convert = new ImageProcess.Converter.Convert(label1.Text, label5.Text, comboBox2.Text);

            convert.Execute();
        }
예제 #3
0
파일: Program.cs 프로젝트: FMI-VT/API
        static void Main(string[] args)
        {
            var srcpath  = "";
            var destpath = "";
            var type     = "";
            int height   = Convert.ToInt32(true);
            int width    = Convert.ToInt32(true);


            Console.WriteLine("Welcome");
            Console.WriteLine("[C]onvert or [R]esize");
            string choice = Console.ReadLine();

            switch (choice.ToUpper())
            {
            case "C":
            {
                Console.WriteLine("Add source image:");
                srcpath = Console.ReadLine();
                Console.WriteLine("Where to save image:");
                destpath = Console.ReadLine();
                Console.WriteLine("Add image type(jpg / gif / png)?");
                type = Console.ReadLine();

                ImageProcess.Converter.Convert convert = new ImageProcess.Converter.Convert(srcpath, destpath, type);
                convert.Execute();
                Console.WriteLine("Done!");
                break;
            }

            case "R":
            {
                Console.WriteLine("Add source image:");
                srcpath = Console.ReadLine();
                Console.WriteLine("Where to save image:");
                destpath = Console.ReadLine();
                Console.WriteLine("Add image height:");
                height = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Add image width:");
                width = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Add resizing type(crop / keepaspect / skew )?");
                type = Console.ReadLine();

                ImageProcess.Resizer.Resize resize = new ImageProcess.Resizer.Resize(srcpath, destpath, type, width, height);
                resize.Execute();
                Console.WriteLine("Done!");
                break;
            }
            }



            // ImageProcess.Resizer.Resize resize = new ImageProcess.Resizer.Resize(srcpath,destpath, type, width, height);
            // resize.Execute();
            // Console.WriteLine("Done!");

            /*
             * ImageProcess.Converter.Convert convert = new ImageProcess.Converter.Convert(@"E:\fox.jpg", @"E:\foxCon.gif", "gif");
             * convert.Execute();
             * Console.WriteLine("Done!");
             *
             * //1.59
             *
             * ImageProcess.Resizer.Resize resize = new ImageProcess.Resizer.Resize(@"E:\fox.jpg", @"E:\fox1.jpg", "keepaspect",350,220 );
             * resize.Execute();
             * Console.WriteLine("Done!");
             *
             *
             * ImageProcess.Resizer.Resize resize = new ImageProcess.Resizer.Resize(@"E:\fox.jpg", @"E:\fox1.jpg", "skew", 480, 220);
             * resize.Execute();
             * Console.WriteLine("Done!");
             */
        }