
11.12.2008, 15:02
|
|
Banned
Регистрация: 22.12.2007
Сообщений: 660
Провел на форуме: 3885269
Репутация:
1158
|
|
Ну просматривать можно примерно так:
Код:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace Image
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
string filename = "";
Bitmap img = new Bitmap(filename);
foreach (PropertyItem imgItem in img.PropertyItems)
MessageBox.Show((Convert.ToString(img.Size)+ Convert.ToString(img.Tag)+
Convert.ToString(img.VerticalResolution)+ Convert.ToString(imgItem.Id)+
Convert.ToString(imgItem.Len)+ Convert.ToString(imgItem.Type)+
Convert.ToString(imgItem.Value)), "Свыше",
MessageBoxButtons.OK, MessageBoxIcon.Information);
//И еще много чего)))
}
}
}
Существует еще класс ImageCodecInfo.
А изменять EXIF можно так (код не мой):
Код:
private void WriteNewDescriptionInImage(string Filename,string NewDescription)
{
Image Pic;
PropertyItem[] PropertyItems;
byte[] bDescription=new Byte[NewDescription.Length];
int i;
string FilenameTemp;
Encoder Enc=Encoder.Transformation;
EncoderParameters EncParms=new EncoderParameters(1);
EncoderParameter EncParm;
ImageCodecInfo CodecInfo=GetEncoderInfo("image/jpeg");
// copy description into byte array
for (i=0;i<NewDescription.Length;i++) bDescription[i]=(byte)NewDescription[i];
// load the image to change
Pic=Image.FromFile(Filename);
// put the new description into the right property item
PropertyItems=Pic.PropertyItems;
PropertyItems[0].Id=0x010e; // 0x010e as specified in EXIF standard
PropertyItems[0].Type=2;
PropertyItems[0].Len=NewDescription.Length;
PropertyItems[0].Value=bDescription;
Pic.SetPropertyItem(PropertyItems[0]);
// we cannot store in the same image, so use a temporary image instead
FilenameTemp=Filename+".temp";
// for lossless rewriting must rotate the image by 90 degrees!
EncParm=new EncoderParameter(Enc,(long)EncoderValue.TransformRotate90);
EncParms.Param[0]=EncParm;
// now write the rotated image with new description
Pic.Save(FilenameTemp,CodecInfo,EncParms);
// for computers with low memory and large pictures: release memory now
Pic.Dispose();
Pic=null;
GC.Collect();
// delete the original file, will be replaced later
System.IO.File.Delete(Filename);
// now must rotate back the written picture
Pic=Image.FromFile(FilenameTemp);
EncParm=new EncoderParameter(Enc,(long)EncoderValue.TransformRotate270);
EncParms.Param[0]=EncParm;
Pic.Save(Filename,CodecInfo,EncParms);
// release memory now
Pic.Dispose();
Pic=null;
GC.Collect();
// delete the temporary picture
System.IO.File.Delete(FilenameTemp);
}
|
|
|