public DirImageRepository (string[] dirnames_in) { num_images = 0; ArrayList dirlist = new ArrayList (); for (int i = 0; i < dirnames_in.Length; i++) { string name = dirnames_in [i].TrimEnd (Util.DirSep); if (Directory.Exists (name)) dirlist.Add (name); } directories = new DirImageCollection [dirlist.Count]; for (int i = 0; i < directories.Length; i++){ directories [i] = new DirImageCollection (this, i, (string) dirlist [i]); num_images += directories [i].Count; foreach (string s in directories [i].Keywords.Keys) keywords [s] = true; } #if NO_MULTITHREAD thumbnailer = new Thumbnailer (); #else thumbnailer = new Thumbnailer (); thumbnailer.OnThumbnailFinished += new Thumbnailer.OnThumbnailFinishedHandler (ThumbnailsAvailable); #endif }
void ThumbnailsAvailable(Thumbnailer t, Thumbnailer.ThumbnailFinishedEventArgs tf) { int i_id = Convert.ToInt32(tf.tinfo.id); if (tf.tinfo.status == ThumbnailStatus.OK) { // save the thumbnail info to the db // only if it was created and was OK SaveThumbToDb(i_id, tf.tinfo.target); } if (tf.tinfo.thumbnail != null) { GetImage(i_id).ImageThumbnail = tf.tinfo.thumbnail; } else { if (tf.tinfo.status == ThumbnailStatus.OK) { // tell the image item to refresh itself, // since we didn't have a pixbuf given to us GetImage(i_id).RefreshThumbnail(); } } }
public DirImageRepository(string[] dirnames_in) { num_images = 0; ArrayList dirlist = new ArrayList(); for (int i = 0; i < dirnames_in.Length; i++) { string name = dirnames_in [i].TrimEnd(Util.DirSep); if (Directory.Exists(name)) { dirlist.Add(name); } } directories = new DirImageCollection [dirlist.Count]; for (int i = 0; i < directories.Length; i++) { directories [i] = new DirImageCollection(this, i, (string)dirlist [i]); num_images += directories [i].Count; foreach (string s in directories[i].Keywords.Keys) { keywords [s] = true; } } #if NO_MULTITHREAD thumbnailer = new Thumbnailer(); #else thumbnailer = new Thumbnailer(); thumbnailer.OnThumbnailFinished += new Thumbnailer.OnThumbnailFinishedHandler(ThumbnailsAvailable); #endif }
public bool RefreshThumb(string exerciseId, string videoId) { var exr = RavenSession.Load <Exercise>("exercises/" + exerciseId); Thumbnailer.GenerateThumbs(exr.Id, exr.VideoId); RavenSession.SaveChanges(); return(true); }
public ActionResult Create(ExerciseViewModel postedModel) { try { if (!ModelState.IsValid) { return(View(postedModel)); } //this code could use some TLC var newExercise = new Exercise(); string[] lines = postedModel.Categories.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); newExercise.Categories = new List <string>(lines.Where(x => !string.IsNullOrWhiteSpace(x))); if (!string.IsNullOrWhiteSpace(postedModel.VideoId)) { newExercise.VideoId = postedModel.VideoId.Trim(); } Ownership.Assign(newExercise, this); if (this.ApplicationAdministrator) { newExercise.Master = true; } newExercise.CreatedOn = DateTime.Now; newExercise.Name = postedModel.Name.Trim(); newExercise.Description = postedModel.Description; RavenSession.Store(newExercise); RavenSession.SaveChanges(); if (!string.IsNullOrWhiteSpace(postedModel.VideoId)) { var success = Thumbnailer.GenerateThumbs(newExercise.Id, newExercise.VideoId); if (!success) { this.WarnUser("We couldn't generate a thumbnail image for this exercise. The video id could be wrong or Vimeo may be not be " + "responding. We'll try to generate the thumbnail again but it would be a good idea to double" + "check the video id. Sorry about that."); } } HighFive("New exercise created ok."); return(RedirectToAction("List")); } catch { return(View(postedModel)); } }
public void ThumbnailsAvailable(Thumbnailer t, Thumbnailer.ThumbnailFinishedEventArgs tf) { string imageid = tf.tinfo.id; if (tf.tinfo.thumbnail != null) { GetImage(imageid).ImageThumbnail = tf.tinfo.thumbnail; } else { if (tf.tinfo.status == ThumbnailStatus.OK) { GetImage(imageid).RefreshThumbnail(); } } }
private void ExportKohlsThumbnail() { if (APathSet.ExportImg) { try { Thumbnailer thN = new Thumbnailer(swApp, APathSet); string[] sht_fmts = { Properties.Settings.Default.ShtFmtPath[0], Properties.Settings.Default.ShtFmtPath[1] }; bool[] monochrome = { false, true }; thN.CreateThumbnails(sht_fmts, monochrome); } catch (ThumbnailerException thEx) { ErrMsg em = new ErrMsg(thEx); em.ShowDialog(); } catch (Exception ex) { ErrMsg em = new ErrMsg(ex); em.ShowDialog(); } } }
static int Main(string [] args) { Application.Init(); // string dbname = "mphoto"; string dbname; string dirtoimport; string mphotodir = System.Environment.GetEnvironmentVariable("HOME") + "/.mphoto"; dbname = "URI=file:" + mphotodir + "/" + "mphoto.db"; IImageRepository repo; System.IO.DirectoryInfo dinfo = new System.IO.DirectoryInfo(mphotodir); dinfo.Create(); // turn on sqlite debugging // int fd = open ("/tmp/sqlite.debug", 576, 420); // sqliteParserTrace (fdopen (fd, "rw"), ">"); if (args.Length != 0) { repo = new DirImageRepository(args); } else { repo = new DbImageRepository(dbname); } MphotoToplevel tl = new MphotoToplevel(repo, args); tl.Toplevel.Show(); try { Application.Run(); } catch (TargetInvocationException e) { Console.WriteLine("TIE: " + e.InnerException); } finally { // yuck DbProvider.CloseProviders(); Thumbnailer.KillThreads(); } return(0); }
public DbImageRepository(string dbstring) { db_conn = DbProvider.GetProvider(dbstring); c_id_array = new ArrayList(); i_id_array = new ArrayList(); collections_hash = new Hashtable(); images_hash = new Hashtable(); id_to_keyword_hash = new Hashtable(); keywords_hash = new Hashtable(); #if NO_MULTITHREAD thumbnailer = new Thumbnailer(); #else thumbnailer = new Thumbnailer(); thumbnailer.OnThumbnailFinished += new Thumbnailer.OnThumbnailFinishedHandler(ThumbnailsAvailable); #endif this.UpdateCollections(); this.UpdateImages(); this.UpdateKeywords(); }
public DbImageRepository (string dbstring) { db_conn = DbProvider.GetProvider (dbstring); c_id_array = new ArrayList (); i_id_array = new ArrayList (); collections_hash = new Hashtable (); images_hash = new Hashtable (); id_to_keyword_hash = new Hashtable (); keywords_hash = new Hashtable (); #if NO_MULTITHREAD thumbnailer = new Thumbnailer (); #else thumbnailer = new Thumbnailer (); thumbnailer.OnThumbnailFinished += new Thumbnailer.OnThumbnailFinishedHandler (ThumbnailsAvailable); #endif this.UpdateCollections (); this.UpdateImages (); this.UpdateKeywords (); }
private void ExportThumbnail() { if (APathSet.ExportImg) { try { Thumbnailer thN = new Thumbnailer(swApp, APathSet); if (thN.assmbly) { thN.CreateThumbnail(); thN.SaveAsJPG(APathSet.JPGPath); thN.CloseThumbnail(); } } catch (ThumbnailerException thEx) { ErrMsg em = new ErrMsg(thEx); em.ShowDialog(); } catch (Exception ex) { ErrMsg em = new ErrMsg(ex); em.ShowDialog(); } } }
public ActionResult Index(string path) { var attachment = MvcApplication.Store.DatabaseCommands.GetAttachment(path); if ((path.Contains("largethumb") || path.Contains("smallthumb")) && attachment == null) { var split = path.Split(new[] { "/" }, StringSplitOptions.None); var attachmentPath = split[0]; var id = split[1]; var exercise = RavenSession.Load <Exercise>("exercises/" + id); if (exercise == null) { exercise = RavenSession.Load <MasterExercise>("masterexercises/" + id); } var originalExerciseAttachment = MvcApplication.Store.DatabaseCommands.GetAttachment(attachmentPath + "/" + exercise.OriginalExercise); if (originalExerciseAttachment != null) { return(new FileStreamResult(originalExerciseAttachment.Data(), "image/jpeg")); } Thumbnailer.GenerateThumbs(exercise.Id, exercise.VideoId); attachment = MvcApplication.Store.DatabaseCommands.GetAttachment(path); } if (attachment == null) { var blankImagePath = Server.MapPath("/content/img/blank.png"); return(new FilePathResult(blankImagePath, "image/png")); } return(new FileStreamResult(attachment.Data(), "image/jpeg")); }
void ThumbnailsAvailable (Thumbnailer t, Thumbnailer.ThumbnailFinishedEventArgs tf) { int i_id = Convert.ToInt32 (tf.tinfo.id); if (tf.tinfo.status == ThumbnailStatus.OK) { // save the thumbnail info to the db // only if it was created and was OK SaveThumbToDb (i_id, tf.tinfo.target); } if (tf.tinfo.thumbnail != null) { GetImage (i_id).ImageThumbnail = tf.tinfo.thumbnail; } else { if (tf.tinfo.status == ThumbnailStatus.OK) { // tell the image item to refresh itself, // since we didn't have a pixbuf given to us GetImage (i_id).RefreshThumbnail (); } } }
public void ThumbnailsAvailable (Thumbnailer t, Thumbnailer.ThumbnailFinishedEventArgs tf) { string imageid = tf.tinfo.id; if (tf.tinfo.thumbnail != null) { GetImage (imageid).ImageThumbnail = tf.tinfo.thumbnail; } else { if (tf.tinfo.status == ThumbnailStatus.OK) { GetImage (imageid).RefreshThumbnail (); } } }