public void WriteInformation(string file, string keyWords)
        {
            var adapter = new JpegMetadataAdapter(file);

            adapter.Metadata.Keywords = keyWords.Split(',');
            bool saved = adapter.Save();
        }
Exemplo n.º 2
0
        static void ValidateMetadataImpl(string jpg, string title, string comment)
        {
            var metadata = new JpegMetadataAdapter(jpg).Metadata;

            Assert.AreEqual(title, metadata.Title);
            Assert.AreEqual(comment, metadata.Comment);
            TraceMetadata(metadata);
        }
Exemplo n.º 3
0
        public void SavePictureMetadata()
        {
            const string title   = "Another Title";
            const string comment = "Another Comment";

            var adapter  = new JpegMetadataAdapter(Jpg);
            var metadata = adapter.Metadata;

            metadata.Title   = title;
            metadata.Comment = comment;
            const string anothersampleJpg = @"Sample\AnotherSample.jpg";

            adapter.SaveAs(anothersampleJpg);
            ValidateMetadataImpl(anothersampleJpg, title, comment);
        }
Exemplo n.º 4
0
 public static string GetFileTags(this string path)
 {
     try
     {
         var metadataKeywords = new JpegMetadataAdapter(path).Metadata?.Keywords;
         if (metadataKeywords != null && metadataKeywords.Count > 0)
         {
             return(string.Join(",", metadataKeywords));
         }
         return(" ");
     }
     catch
     {
         return(" ");
     }
 }
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);    // Process the message

            if ((m.Msg == WM_DRAWCLIPBOARD) && (tb_FolderDirectory.Text != string.Empty))
            {
                IDataObject iData = Clipboard.GetDataObject();      // Clipboard's data

                if (iData.GetDataPresent(DataFormats.Bitmap))
                {
                    Bitmap image = (Bitmap)iData.GetData(DataFormats.Bitmap);   // Get clipboard image

                    Form_ImageDescription form_imagedescription = new Form_ImageDescription();
                    form_imagedescription.TopMost = true;                   //  Set form priority before showing it so it stays topmost
                    form_imagedescription.imageproperties.image = image;    //  Pass image to child form

                    form_imagedescription.ShowDialog();

                    //  Only save comment and captured image if user clicked ok in ImageDescription form
                    if (form_imagedescription.imageproperties.imagesaved == true)
                    {
                        ImageCodecInfo jgpEncoder = GetEncoder(ImageFormat.Jpeg);
                        System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality;

                        EncoderParameters myEncoderParameters = new EncoderParameters(1);

                        EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 100L);
                        myEncoderParameters.Param[0] = myEncoderParameter;

                        //  Name image according to current time in .jpg format
                        string current_time = DateTime.Now.ToString("yyyyMMddHHmmss");
                        image.Save(tb_FolderDirectory.Text + "\\" + current_time + ".jpg", jgpEncoder, myEncoderParameters);

                        //  Add the comment and save
                        JpegMetadataAdapter jpeg = new JpegMetadataAdapter(tb_FolderDirectory.Text + "\\" + current_time + ".jpg");
                        jpeg.Metadata.Comment = form_imagedescription.imageproperties.comment;
                        jpeg.Save();
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void Button6_Click(object sender, EventArgs e)
        {
            g = resim.CreateGraphics();

            g.DrawRectangle(_pencil, mx - 40, my - 40, 95, 105);

            var jpeg = new JpegMetadataAdapter(resimYolu);

            string koordinatBilgisi = "";


            koordinatBilgisi = "Pin  X : " + mx + " Y : " + my + "\n";

            jpeg.Metadata.Comment = koordinatBilgisi;
            jpeg.Metadata.Title   = "Koordinatlar \n";
            // jpeg.Save();            // Resmin kendisine kayıt etme istenirse yapılabilir.

            string gsrYol = @"D:\Downloads\TezOdev" + resimAdi + " GsrDosyası.gsr"; //kaydedeceğimiz GSR Dosyasının yolunu belirle

            jpeg.SaveAs(gsrYol);                                                    // GSR Dosyası olarak kaydet

            MessageBox.Show("GSR Dosyası Başarıyla Kaydedildi.");
        }
Exemplo n.º 7
0
        public void ReadPictureMetadata()
        {
            var metadata = new JpegMetadataAdapter(Jpg).Metadata;

            TraceMetadata(metadata);
        }
Exemplo n.º 8
0
        //Function to rename File in this format: "ParentFolder_YYYY-MM-DD_HH.MM.SS"
        public static void renameFile(string parentFolder) //path have to be in format: @"C:\dir\..."
        {
            // Skip if the directory not exists
            if (!Fonctions.IO.DirectoryExsiste(parentFolder))
            {
                return;
            }

            string fRename     = null;
            string year        = null;
            string month       = null;
            string day         = null;
            string hour        = null;
            string minute      = null;
            string seconde     = null;
            string correctDate = null;
            string fExt        = null; //file Extension
            int    i           = 0;

            //Get info of the parentfolder and concatene the space
            DirectoryInfo d      = new DirectoryInfo(parentFolder);
            string        folder = d.Name;

            folder = Regex.Replace(folder, @"\s+", "");       //Regex is love Regex is life (by Julien Richoz parce que Davide ne veut pas avoir 2)

            //Copy all jpeg files from pathFile to files array
            FileInfo[] infos = d.GetFiles("*.jpg");
            //loop through all files
            foreach (FileInfo f in infos)
            {
                //Get the extension of the file
                fExt = Path.GetExtension(f.Name);
                //Get the date taken of the files via Metadata
                var    adapter  = new JpegMetadataAdapter(f.FullName);
                string dateFile = adapter.Metadata.DateTaken;

                //Sort the string date
                if (dateFile.Length > 13)
                {
                    year   = dateFile.Substring(6, 4);
                    month  = dateFile.Substring(3, 2);
                    day    = dateFile.Substring(0, 2);
                    hour   = dateFile.Substring(11, 2);
                    minute = dateFile.Substring(14, 2);
                    if (dateFile.Length > 16)
                    {
                        seconde = dateFile.Substring(17, 2);
                    }
                    else
                    {
                        seconde = null;
                    }
                    correctDate = year + "-" + month + "-" + day + "_" + hour + "." + minute;
                    if (seconde != null)
                    {
                        correctDate += "." + seconde;
                    }
                }
                else
                {
                    i++;
                    correctDate = "NoDateTaken" + i.ToString(); //Inform the user that there is no date taken. Added +i to avoid duplication
                }

                fRename = folder + "_" + correctDate + fExt;
                string destFile = d + "\\" + fRename;
                if (!File.Exists(destFile))
                {
                    File.Move(f.FullName, destFile);
                }
            }
        }
        private void tb_ImageDescription_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (pb_picturebox.Image != null)
                {
                    //  Save new comments, restore button visibility and disable Imagedescription box
                    JpegMetadataAdapter jpeg = new JpegMetadataAdapter(pb_picturebox.ImageLocation);
                    jpeg.Metadata.Comment = tb_ImageDescription.Text;
                    jpeg.Save();

                    btn_Edit.Visible = true;
                    btn_Save.Visible = false;
                    tb_ImageDescription.Enabled = false;
                }
            }
        }
Exemplo n.º 10
0
        private void listview_ImageList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listview_ImageList.FocusedItem.Index >= 0)
            {
                //  Get image location for display
                pb_picturebox.ImageLocation = m_captured_image_list[listview_ImageList.FocusedItem.Index].image_path;

                //  Set size mode so that image fits within picturebox
                pb_picturebox.SizeMode = PictureBoxSizeMode.Zoom;

                //  Display the existing comment from image Metadata
                JpegMetadataAdapter jpeg = new JpegMetadataAdapter(pb_picturebox.ImageLocation);
                tb_ImageDescription.Text = jpeg.Metadata.Comment;
            }
        }