示例#1
0
            public void TestSave()
            {
                string            desc   = "this is an example description";
                string            desc2  = "\x00a9 Novell Inc.";
                PixbufOrientation orient = PixbufOrientation.TopRight;

                Gdk.Pixbuf test = new Gdk.Pixbuf(null, "f-spot-32.png");
                string     path = ImageFile.TempPath("joe.jpg");

                PixbufUtils.SaveJpeg(test, path, 75, new Exif.ExifData());
                JpegFile jimg = new JpegFile(path);

                jimg.SetDescription(desc);
                jimg.SetOrientation(orient);
                jimg.SaveMetaData(path);
                JpegFile mod = new JpegFile(path);

                Assert.AreEqual(mod.Orientation, orient);
                Assert.AreEqual(mod.Description, desc);
                jimg.SetDescription(desc2);
                jimg.SaveMetaData(path);
                mod = new JpegFile(path);
                Assert.AreEqual(mod.Description, desc2);

                File.Delete(path);
            }
示例#2
0
        private static void RotateOrientation(string original_path, RotateDirection direction)
        {
            using (FSpot.ImageFile img = FSpot.ImageFile.Create(original_path)) {
                if (img is JpegFile)
                {
                    FSpot.JpegFile    jimg        = img as FSpot.JpegFile;
                    PixbufOrientation orientation = direction == RotateDirection.Clockwise
                                                ? PixbufUtils.Rotate90(img.Orientation)
                                                : PixbufUtils.Rotate270(img.Orientation);

                    jimg.SetOrientation(orientation);
                    jimg.SaveMetaData(original_path);
                }
                else if (img is PngFile)
                {
                    PngFile png       = img as PngFile;
                    bool    supported = false;

                    //FIXME there isn't much png specific here except the check
                    //the pixbuf is an accurate representation of the real file
                    //by checking the depth.  The check should be abstracted and
                    //this code made generic.
                    foreach (PngFile.Chunk c in png.Chunks)
                    {
                        PngFile.IhdrChunk ihdr = c as PngFile.IhdrChunk;

                        if (ihdr != null && ihdr.Depth == 8)
                        {
                            supported = true;
                        }
                    }

                    if (!supported)
                    {
                        throw new RotateException("Unable to rotate photo type", original_path);
                    }

                    string backup = ImageFile.TempPath(original_path);
                    using (Stream stream = File.Open(backup, FileMode.Truncate, FileAccess.Write)) {
                        using (Pixbuf pixbuf = img.Load()) {
                            PixbufOrientation fake = (direction == RotateDirection.Clockwise) ? PixbufOrientation.RightTop : PixbufOrientation.LeftBottom;
                            using (Pixbuf rotated = PixbufUtils.TransformOrientation(pixbuf, fake)) {
                                img.Save(rotated, stream);
                            }
                        }
                    }
                    File.Copy(backup, original_path, true);
                    File.Delete(backup);
                }
                else
                {
                    throw new RotateException("Unable to rotate photo type", original_path);
                }
            }
        }
示例#3
0
        public string CreateFile()
        {
            Gdk.Pixbuf        test   = new Gdk.Pixbuf(null, "f-spot-32.png");
            string            path   = FSpot.ImageFile.TempPath("joe.jpg");
            string            desc   = "\x00a9 Novell Inc.";
            PixbufOrientation orient = PixbufOrientation.TopRight;

            PixbufUtils.SaveJpeg(test, path, quality, new Exif.ExifData());
            FSpot.JpegFile jimg = new FSpot.JpegFile(path);
            jimg.SetDescription(desc);
            jimg.SetOrientation(orient);
            jimg.SaveMetaData(path);

            return(path);
        }
示例#4
0
		public void Save ()
		{
			string desc = "this is an example description";
			string desc2 = "\x00a9 Novell Inc.";
			PixbufOrientation orient = PixbufOrientation.TopRight;
			Gdk.Pixbuf test = new Gdk.Pixbuf (null, "f-spot-32.png");
			string path = ImageFile.TempPath ("joe.jpg");
			
			PixbufUtils.SaveJpeg (test, path, 75, new Exif.ExifData ());
			JpegFile jimg = new JpegFile (path);
			jimg.SetDescription (desc);
			jimg.SetOrientation (orient);
			jimg.SaveMetaData (path);
			JpegFile mod = new JpegFile (path);
			Assert.AreEqual (mod.Orientation, orient);
			Assert.AreEqual (mod.Description, desc);
			jimg.SetDescription (desc2);
			jimg.SaveMetaData (path);
			mod = new JpegFile (path);
			Assert.AreEqual (mod.Description, desc2);
			
			Header header = mod.ExifHeader;
#if USE_TEST_FILE
			string tmp = "/home/lewing/test.tiff";
			if (File.Exists (tmp))
				File.Delete (tmp);
			Stream stream = File.Open (tmp, FileMode.Create, FileAccess.ReadWrite);
			Console.WriteLine ("XXXX saving tiff {0}", tmp);
#else
			System.IO.MemoryStream stream = new System.IO.MemoryStream ();
#endif

			header.Dump ("source");
			header.Save (stream);
			stream.Position = 0;
			System.Console.WriteLine ("----------------------------------------------LOADING TIFF");
			Header loader = new Header (stream);
			loader.Dump ("loader");
			
			CompareDirectories (header.Directory, loader.Directory);

			System.IO.File.Delete (path);	
		}
示例#5
0
		public string CreateFile ()
		{
			Gdk.Pixbuf test = new Gdk.Pixbuf (null, "f-spot-32.png");
			string path = FSpot.ImageFile.TempPath ("joe.jpg");
			string desc = "\x00a9 Novell Inc.";
			PixbufOrientation orient = PixbufOrientation.TopRight;

			PixbufUtils.SaveJpeg (test, path, quality, new Exif.ExifData ());
			FSpot.JpegFile jimg = new FSpot.JpegFile (path);
			jimg.SetDescription (desc);
			jimg.SetOrientation (orient);
			jimg.SaveMetaData (path);
			
			return path;
		}
			public void TestSave ()
			{
				string desc = "this is an example description";
				string desc2 = "\x00a9 Novell Inc.";
				PixbufOrientation orient = PixbufOrientation.TopRight;
				Gdk.Pixbuf test = new Gdk.Pixbuf (null, "f-spot-32.png");
				string path = ImageFile.TempPath ("joe.jpg");
				
				PixbufUtils.SaveJpeg (test, path, 75, new Exif.ExifData ());
				JpegFile jimg = new JpegFile (path);
				jimg.SetDescription (desc);
				jimg.SetOrientation (orient);
				jimg.SaveMetaData (path);
				JpegFile mod = new JpegFile (path);
				Assert.AreEqual (mod.Orientation, orient);
				Assert.AreEqual (mod.Description, desc);
				jimg.SetDescription (desc2);
				jimg.SaveMetaData (path);
				mod = new JpegFile (path);
				Assert.AreEqual (mod.Description, desc2);
				
				File.Delete (path);
			}