コード例 #1
0
		private int ImportFiles ()
		{
			ImportCommand command = new ImportCommand (null);
			return command.ImportFromPaths (db.Photos, saved_files, selected_tags);
		}
コード例 #2
0
ファイル: PictureTile.cs プロジェクト: Yetangitu/f-spot
        void CreatePhotoWall()
        {
            dir_tmp = System.IO.Path.GetTempFileName ();
            System.IO.File.Delete (dir_tmp);
            System.IO.Directory.CreateDirectory (dir_tmp);
            dir_tmp += "/";

            //Prepare the pictures
            ProgressDialog progress_dialog = null;
            progress_dialog = new ProgressDialog (Catalog.GetString ("Preparing selected pictures"),
                                  ProgressDialog.CancelButtonType.Stop,
                                  App.Instance.Organizer.SelectedPhotos ().Length, picturetile_dialog);

            FilterSet filters = new FilterSet ();
            filters.Add (new JpegFilter ());
            uint counter = 0;
            List<Tag> all_tags = new List<Tag> ();
            foreach (Photo p in App.Instance.Organizer.SelectedPhotos ()) {
                if (progress_dialog.Update (String.Format (Catalog.GetString ("Processing \"{0}\""), p.Name))) {
                    progress_dialog.Destroy ();
                    DeleteTmp ();
                    return;
                }

                //Store photo tags, to attach them later on import
                foreach (Tag tag in p.Tags) {
                    if (! all_tags.Contains (tag))
                        all_tags.Add (tag);
                }

                //FIXME should switch to retry/skip
                if (!GLib.FileFactory.NewForUri (p.DefaultVersion.Uri).Exists) {
                    Log.WarningFormat ("Couldn't access photo {0} while creating mosaics", p.DefaultVersion.Uri.LocalPath);
                    continue;
                }

                using (FilterRequest freq = new FilterRequest (p.DefaultVersion.Uri)) {
                    filters.Convert (freq);
                    File.Copy (freq.Current.LocalPath, String.Format ("{0}{1}.jpg", dir_tmp, counter ++));
                }
            }
            if (progress_dialog != null)
                progress_dialog.Destroy ();

            photo_tags = all_tags.ToArray ();

            string uniform = "";
            if (uniform_images.Active)
                uniform = "--uniform";
            string output_format = "jpeg";
            if (tiff_radio.Active)
                output_format = "tiff";
            string scale = String.Format (CultureInfo.InvariantCulture, "{0,4}", (double) image_scale.Value / (double) 100);

            destfile_tmp = String.Format ("{0}.{1}", System.IO.Path.GetTempFileName (), output_format);

            //Execute picturetile
            string picturetile_command = String.Format ("--size {0}x{1} " +
                                    "--directory {2} " +
                                    "--scale {3} " +
                                    "--margin {4} " +
                                    "--border {5} " +
                                    "--background {6} " +
                                    "--pages {7} " +
                                    "{8} " +
                                    "{9}",
                                x_max_size.Text,
                                y_max_size.Text,
                                dir_tmp,
                                scale,
                                space_between_images.Text,
                                outside_border.Text,
                                colors [background_color.Active],
                                pages.Text,
                                uniform,
                                destfile_tmp);
            Log.Debug ("Executing: picturetile.pl " + picturetile_command);
            System.Diagnostics.Process pt_exe = System.Diagnostics.Process.Start ("picturetile.pl", picturetile_command);
            pt_exe.WaitForExit ();

            // Handle multiple files generation (pages).
            // If the user wants 2 pages (images), and the output filename is out.jpg, picturetile will create
            // /tmp/out1.jpg and /tmp/out2.jpg.
            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo (System.IO.Path.GetDirectoryName (destfile_tmp));
            string filemask = System.IO.Path.GetFileNameWithoutExtension (destfile_tmp) + "*" + System.IO.Path.GetExtension (destfile_tmp);
            FileInfo [] fi = di.GetFiles (filemask);

            // Move generated files to f-spot photodir
            string [] photo_import_list = new string [fi.Length];
            counter = 0;
            foreach (FileInfo f in fi) {
                string orig = System.IO.Path.Combine (f.DirectoryName, f.Name);
                photo_import_list [counter ++] = MoveFile (orig);
            }

            //Add the pic(s) to F-Spot!
            Db db = App.Instance.Database;
            ImportCommand command = new ImportCommand (null);
            if (command.ImportFromPaths (db.Photos, photo_import_list, photo_tags) > 0) {
                InfoDialog (Catalog.GetString ("PhotoWall generated!"),
                        Catalog.GetString ("Your photo wall have been generated and imported in F-Spot. Select the last roll to see it"),
                        Gtk.MessageType.Info);
            } else {
                InfoDialog (Catalog.GetString ("Error importing photowall"),
                        Catalog.GetString ("An error occurred while importing the newly generated photowall to F-Spot"),
                        Gtk.MessageType.Error);
            }
            DeleteTmp ();
        }
コード例 #3
0
	public void ImportUriList (UriList list, bool copy) 
	{
		ImportCommand command = new ImportCommand (main_window);
		if (command.ImportFromPaths (db.Photos, list.ToLocalPaths (), copy) > 0) {
			query.RollSet = new RollSet (db.Rolls.GetRolls (1)[0]);
			UpdateQuery ();
		}
	}
コード例 #4
0
        private int ImportFiles()
        {
            ImportCommand command = new ImportCommand(null);

            return(command.ImportFromPaths(db.Photos, saved_files, selected_tags));
        }
コード例 #5
0
        private void ImportFiles()
        {
            ImportCommand command = new ImportCommand(null);

            command.ImportFromPaths(db.Photos, saved_files, selected_tags);
        }
コード例 #6
0
        void CreatePhotoWall()
        {
            dir_tmp = System.IO.Path.GetTempFileName();
            System.IO.File.Delete(dir_tmp);
            System.IO.Directory.CreateDirectory(dir_tmp);
            dir_tmp += "/";

            //Prepare the pictures
            ProgressDialog progress_dialog = null;

            progress_dialog = new ProgressDialog(Catalog.GetString("Preparing selected pictures"),
                                                 ProgressDialog.CancelButtonType.Stop,
                                                 App.Instance.Organizer.SelectedPhotos().Length, picturetile_dialog);

            FilterSet filters = new FilterSet();

            filters.Add(new JpegFilter());
            uint       counter  = 0;
            List <Tag> all_tags = new List <Tag> ();

            foreach (Photo p in App.Instance.Organizer.SelectedPhotos())
            {
                if (progress_dialog.Update(String.Format(Catalog.GetString("Processing \"{0}\""), p.Name)))
                {
                    progress_dialog.Destroy();
                    DeleteTmp();
                    return;
                }

                //Store photo tags, to attach them later on import
                foreach (Tag tag in p.Tags)
                {
                    if (!all_tags.Contains(tag))
                    {
                        all_tags.Add(tag);
                    }
                }

                //FIXME should switch to retry/skip
                if (!GLib.FileFactory.NewForUri(p.DefaultVersion.Uri).Exists)
                {
                    Log.WarningFormat("Couldn't access photo {0} while creating mosaics", p.DefaultVersion.Uri.LocalPath);
                    continue;
                }

                using (FilterRequest freq = new FilterRequest(p.DefaultVersion.Uri)) {
                    filters.Convert(freq);
                    File.Copy(freq.Current.LocalPath, String.Format("{0}{1}.jpg", dir_tmp, counter++));
                }
            }
            if (progress_dialog != null)
            {
                progress_dialog.Destroy();
            }

            photo_tags = all_tags.ToArray();

            string uniform = "";

            if (uniform_images.Active)
            {
                uniform = "--uniform";
            }
            string output_format = "jpeg";

            if (tiff_radio.Active)
            {
                output_format = "tiff";
            }
            string scale = String.Format(CultureInfo.InvariantCulture, "{0,4}", (double)image_scale.Value / (double)100);

            destfile_tmp = String.Format("{0}.{1}", System.IO.Path.GetTempFileName(), output_format);

            //Execute picturetile
            string picturetile_command = String.Format("--size {0}x{1} " +
                                                       "--directory {2} " +
                                                       "--scale {3} " +
                                                       "--margin {4} " +
                                                       "--border {5} " +
                                                       "--background {6} " +
                                                       "--pages {7} " +
                                                       "{8} " +
                                                       "{9}",
                                                       x_max_size.Text,
                                                       y_max_size.Text,
                                                       dir_tmp,
                                                       scale,
                                                       space_between_images.Text,
                                                       outside_border.Text,
                                                       colors [background_color.Active],
                                                       pages.Text,
                                                       uniform,
                                                       destfile_tmp);

            Log.Debug("Executing: picturetile.pl " + picturetile_command);
            System.Diagnostics.Process pt_exe = System.Diagnostics.Process.Start("picturetile.pl", picturetile_command);
            pt_exe.WaitForExit();

            // Handle multiple files generation (pages).
            // If the user wants 2 pages (images), and the output filename is out.jpg, picturetile will create
            // /tmp/out1.jpg and /tmp/out2.jpg.
            System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(System.IO.Path.GetDirectoryName(destfile_tmp));
            string filemask            = System.IO.Path.GetFileNameWithoutExtension(destfile_tmp) + "*" + System.IO.Path.GetExtension(destfile_tmp);

            FileInfo [] fi = di.GetFiles(filemask);

            // Move generated files to f-spot photodir
            string [] photo_import_list = new string [fi.Length];
            counter = 0;
            foreach (FileInfo f in fi)
            {
                string orig = System.IO.Path.Combine(f.DirectoryName, f.Name);
                photo_import_list [counter++] = MoveFile(orig);
            }

            //Add the pic(s) to F-Spot!
            Db            db      = App.Instance.Database;
            ImportCommand command = new ImportCommand(null);

            if (command.ImportFromPaths(db.Photos, photo_import_list, photo_tags) > 0)
            {
                InfoDialog(Catalog.GetString("PhotoWall generated!"),
                           Catalog.GetString("Your photo wall have been generated and imported in F-Spot. Select the last roll to see it"),
                           Gtk.MessageType.Info);
            }
            else
            {
                InfoDialog(Catalog.GetString("Error importing photowall"),
                           Catalog.GetString("An error occurred while importing the newly generated photowall to F-Spot"),
                           Gtk.MessageType.Error);
            }
            DeleteTmp();
        }