Esempio n. 1
0
 public ExifImage(BitmapImage imageSource, JpegInfo info)
 {
     PixelWidth = imageSource.PixelWidth;
     PixelHeight = imageSource.PixelHeight;
     AspectRatio = (double)PixelWidth / (double)PixelHeight;
     Image = new Image();
     Image.Source = imageSource;
     ImageInfo = info;
 }
Esempio n. 2
0
    void FetchImages()
    {
        //get file names from input text file.
        string[] lines = System.IO.File.ReadAllLines("sdcard/MyFamilyResources/ImageAudio.txt");

        string[] image_names = new string[lines.Length];
        audio_names = new string[lines.Length];

        int i = 0;

        foreach (string line in lines)
        {
            // Use a tab to indent each line of the file.
            string[] data = line.Split(' ');
            image_names[i] = data[0];
            audio_names[i] = data[1];

            i++;
        }

        // Function to load images from Android File System
        string path1      = "sdcard/MyFamilyResources/Images/";
        string pathPreFix = @"file://";

        textList  = new Texture2D[image_names.Length];// init the list of textures.
        audioSrcs = new AudioSource[audio_names.Length];

        int index = 0;

        while (index < frameCount)
        {
            WWW www = new WWW(pathPreFix + path1 + image_names[index]);
            //yield return www;
            ExifLib.JpegInfo jpi = ExifLib.ExifReader.ReadJpeg(www.bytes, (index + 1).ToString());

            string orientation = jpi.Orientation.ToString();
            if (orientation == "TopRight")
            {
                textList[index] = rotate90(www.texture);
            }
            else if (orientation == "BottomLeft")
            {
                textList[index] = rotateMinus90(www.texture);
            }
            else //if (orientation == "TopLeft")
            {
                textList[index] = www.texture;
            }

            index++;
        }
    }
Esempio n. 3
0
    /// <summary>
    /// ExifLib - http://www.codeproject.com/Articles/47486/Understanding-and-Reading-Exif-Data
    /// </summary>


    IEnumerator LoadByteArrayIntoTexture(string url)
    {
        UnityWebRequest www = UnityWebRequest.Get(url);

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            // retrieve results as binary data
            byte[] results = www.downloadHandler.data;

            Debug.Log("Finished Getting Image -> SIZE: " + results.Length.ToString());
            ExifLib.JpegInfo jpi = ExifLib.ExifReader.ReadJpeg(results, "Sample File");


            double[] Latitude  = jpi.GpsLatitude;
            double[] Longitude = jpi.GpsLongitude;
            orientationString = jpi.Orientation.ToString();

            ExifData.text = "<b>Exif Data:</b>" + "<color=white>";
            ExifData.text = ExifData.text + "\n" + "FileName: " + jpi.FileName;
            ExifData.text = ExifData.text + "\n" + "DateTime: " + jpi.DateTime;
            ExifData.text = ExifData.text + "\n" + "GpsLatitude: " + Latitude[0] + "° " + Latitude[1] + "' " + Latitude[2] + '"';
            ExifData.text = ExifData.text + "\n" + "GpsLongitude: " + Longitude[0] + "° " + Longitude[1] + "' " + Longitude[2] + '"';
            ExifData.text = ExifData.text + "\n" + "Description: " + jpi.Description;
            ExifData.text = ExifData.text + "\n" + "Height: " + jpi.Height + " pixels";
            ExifData.text = ExifData.text + "\n" + "Width: " + jpi.Width + " pixels";
            ExifData.text = ExifData.text + "\n" + "ResolutionUnit: " + jpi.ResolutionUnit;
            ExifData.text = ExifData.text + "\n" + "UserComment: " + jpi.UserComment;
            ExifData.text = ExifData.text + "\n" + "Make: " + jpi.Make;
            ExifData.text = ExifData.text + "\n" + "Model: " + jpi.Model;
            ExifData.text = ExifData.text + "\n" + "Software: " + jpi.Software;
            ExifData.text = ExifData.text + "\n" + "Orientation: " + orientationString;
            ExifData.text = ExifData.text + "</color>";

            Texture2D tex = new Texture2D(2, 2);
            tex.LoadImage(results);
            newTexture = tex;

            // Not sure why, but many images come in flipped 180 degrees
            //newTexture = rotateTexture(newTexture, true); // Rotate clockwise 90 degrees
            //newTexture = rotateTexture(newTexture, true); // Rotate clockwise 90 degrees (again, to flip it)
            this.texture = newTexture;
        }
    }
Esempio n. 4
0
    /// <summary>
    /// ExifLib - http://www.codeproject.com/Articles/47486/Understanding-and-Reading-Exif-Data
    /// </summary>
    IEnumerator GetImage(string url)
    {
        WWW www = new WWW(url);

        Debug.Log("Fetching image " + url);
        yield return(www);

        if (!System.String.IsNullOrEmpty(www.error))
        {
            Debug.Log(www.error);
            this.texture = null;
        }
        else
        {
            Debug.Log("Finished Getting Image -> SIZE: " + www.bytes.Length.ToString());
            ExifLib.JpegInfo jpi = ExifLib.ExifReader.ReadJpeg(www.bytes, "Foo");
            Debug.Log("EXIF: " + jpi.Orientation.ToString());
            Debug.Log("EXIF: " + jpi.Model);
            this.texture = www.texture;
        }
    }
Esempio n. 5
0
        private void ReadExif(JpegInfo info)
        {
            artist.Text = "Artist: " + info.Artist;
            copyright.Text = "Copyright: " + info.Copyright;
            datetime.Text = "Datetime: " + info.DateTime;
            description.Text = "Description: " + info.Description;
            exposure.Text = "Exposure: " + info.ExposureTime;
            filename.Text = "File name: " + info.FileName;
            filesize.Text = "File size: " + info.FileSize;
            flash.Text = "Flash: " + info.Flash;
            fnumber.Text = "F number: " + info.FNumber;
            gpslatitude.Text = "GPS Latitude: " + info.GpsLatitude;
            gpslatituderef.Text = "GPS Latitude ref: " + info.GpsLatitudeRef;
            gpslongitude.Text = "GPS Longitude: " + info.GpsLongitude;
            gpslongituderef.Text = "GPS Longitude ref: " + info.GpsLongitudeRef;
            height.Text = "Height: " + info.Height;
            iscolor.Text = "Is color: " + info.IsColor;
            isvalid.Text = "Is valid: " + info.IsValid;
            loadtime.Text = "Load time: " + info.LoadTime;
            make.Text = "Make: " + info.Make;
            orientation.Text = "Orientation: " + info.Orientation;
            resolutionunit.Text = "Resolution unit: " + info.ResolutionUnit;
            software.Text = "Software: " + info.Software;
            thumbdata.Text = "Thumbnail data: " + info.ThumbnailData;
            thumboffset.Text = "Thumbnail offset: " + info.ThumbnailOffset;
            thumbsize.Text = "Thumbnail size: " + info.ThumbnailSize;
            usercomment.Text = "User comment: " + info.UserComment;
            width.Text = "Width: " + info.Width;
            xresolution.Text = "X resolution: " + info.XResolution;
            yresolution.Text = "Y resolution: " + info.YResolution;
            photoLoaded = true;

           if( info.Width == 2000)
           {
               wid.Text = "de";
           }
        }
Esempio n. 6
0
    IEnumerator LoadPictureCoroutine(string path)
    {
        WWW www = new WWW(path);

        if (www.size == 0)
        {
            showlog("size 0");
            yield return(new WaitForSeconds(1.0f));

            LoadPicture(path);
        }
        else if (!string.IsNullOrEmpty(www.error))
        {
            showlog("error");
            PictureLoaded(false, null, null);
        }
        else
        {
            ExifLib.JpegInfo jpi = ExifLib.ExifReader.ReadJpeg(www.bytes, "test2.jpg");
            showlog("EXIF: " + jpi.Orientation);

            Texture2D texture = new Texture2D(www.texture.width, www.texture.height, TextureFormat.RGB24, false);

            texture.anisoLevel = 1;
            texture.filterMode = FilterMode.Bilinear;
            texture.wrapMode   = TextureWrapMode.Clamp;

            www.LoadImageIntoTexture(texture);

            TextureScale.Bilinear(texture, texture.width / 10, texture.height / 10);
            texture = TextureRotate.RotateImage(texture, -90);

            Sprite picture = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero, 1);
            PictureLoaded(true, path, picture);
        }
    }
Esempio n. 7
0
        protected ExifReader(Stream stream)
        {
            info = new JpegInfo();
            int a = stream.ReadByte();

            // ensure SOI marker
            if (a != JpegId.START || stream.ReadByte() != JpegId.SOI)
                return;

            info.IsValid = true;

            for (; ; )
            {
                int marker = 0, prev = 0;

                // find next marker
                for (a = 0; ; ++a)
                {
                    marker = stream.ReadByte();
                    if (marker != JpegId.START && prev == JpegId.START) break;
                    prev = marker;
                }

                // read section length
                int lenHigh = stream.ReadByte();
                int lenLow = stream.ReadByte();
                int itemlen = (lenHigh << 8) | lenLow;

                // read the section
                byte[] section = new byte[itemlen];
                section[0] = (byte)lenHigh;
                section[1] = (byte)lenLow;
                int bytesRead = stream.Read(section, 2, itemlen - 2);
                if (bytesRead != itemlen - 2)
                    return;

                switch (marker)
                {
                    case JpegId.SOS:
                        // start of stream: and we're done
                        return;
                    case JpegId.EOI:
                        // no data? no good.
                        return;
                    case JpegId.EXIF:
                        {
                            if (section[2] == 'E' &&
                                section[3] == 'x' &&
                                section[4] == 'i' &&
                                section[5] == 'f')
                            {
                                ProcessExif(section);
                            }
                        } break;
                    case JpegId.IPTC:
                        {
                            // don't care.
                        } break;
                    case 0xC0:
                    case 0xC1:
                    case 0xC2:
                    case 0xC3:
                    // case 0xC4: // not SOF
                    case 0xC5:
                    case 0xC6:
                    case 0xC7:
                    // case 0xC8: // not SOF
                    case 0xC9:
                    case 0xCA:
                    case 0xCB:
                    // case 0xCC: // not SOF
                    case 0xCD:
                    case 0xCE:
                    case 0xCF:
                        {
                            ProcessSOF(section, marker);
                        } break;
                    default:
                        {
                            // don't care.
                        } break;
                }

                section = null;
                GC.Collect();
            }
        }
Esempio n. 8
0
        public virtual void Populate(JpegInfo info, ExifIFD ifd)
        {
            if (ifd == ExifIFD.Exif)
            {
                switch ((ExifId)this.Tag)
                {
                case ExifId.ImageWidth: info.Width = GetInt(0); break;

                case ExifId.ImageHeight: info.Height = GetInt(0); break;

                case ExifId.Orientation: info.Orientation = (ExifOrientation)GetInt(0); break;

                case ExifId.XResolution: info.XResolution = GetNumericValue(0); break;

                case ExifId.YResolution: info.YResolution = GetNumericValue(0); break;

                case ExifId.ResolutionUnit: info.ResolutionUnit = (ExifUnit)GetInt(0); break;

                case ExifId.DateTime: info.DateTime = GetStringValue(); break;

                case ExifId.DateTimeOriginal: info.DateTimeOriginal = GetStringValue(); break;

                case ExifId.Description: info.Description = GetStringValue(); break;

                case ExifId.Make: info.Make = GetStringValue(); break;

                case ExifId.Model: info.Model = GetStringValue(); break;

                case ExifId.Software: info.Software = GetStringValue(); break;

                case ExifId.Artist: info.Artist = GetStringValue(); break;

                case ExifId.ThumbnailOffset: info.ThumbnailOffset = GetInt(0); break;

                case ExifId.ThumbnailLength: info.ThumbnailSize = GetInt(0); break;

                case ExifId.Copyright: info.Copyright = GetStringValue(); break;

                case ExifId.UserComment: info.UserComment = GetStringValue(); break;

                case ExifId.ExposureTime: info.ExposureTime = GetNumericValue(0); break;

                case ExifId.FNumber: info.FNumber = GetNumericValue(0); break;

                case ExifId.FlashUsed: info.Flash = (ExifFlash)GetInt(0); break;

                default: break;
                }
            }
            else if (ifd == ExifIFD.Gps)
            {
                switch ((ExifGps)this.Tag)
                {
                case ExifGps.LatitudeRef:
                {
                    if (GetStringValue() == "N")
                    {
                        info.GpsLatitudeRef = ExifGpsLatitudeRef.North;
                    }
                    else if (GetStringValue() == "S")
                    {
                        info.GpsLatitudeRef = ExifGpsLatitudeRef.South;
                    }
                } break;

                case ExifGps.LongitudeRef:
                {
                    if (GetStringValue() == "E")
                    {
                        info.GpsLongitudeRef = ExifGpsLongitudeRef.East;
                    }
                    else if (GetStringValue() == "W")
                    {
                        info.GpsLongitudeRef = ExifGpsLongitudeRef.West;
                    }
                } break;

                case ExifGps.Latitude:
                {
                    if (Components == 3)
                    {
                        info.GpsLatitude[0] = GetNumericValue(0);
                        info.GpsLatitude[1] = GetNumericValue(1);
                        info.GpsLatitude[2] = GetNumericValue(2);
                    }
                } break;

                case ExifGps.Longitude:
                {
                    if (Components == 3)
                    {
                        info.GpsLongitude[0] = GetNumericValue(0);
                        info.GpsLongitude[1] = GetNumericValue(1);
                        info.GpsLongitude[2] = GetNumericValue(2);
                    }
                } break;
                }
            }
        }
Esempio n. 9
0
        protected ExifReader(Stream stream)
        {
            info = new JpegInfo();
            int a = stream.ReadByte();

            // ensure SOI marker
            if (a != JpegId.START || stream.ReadByte() != JpegId.SOI)
            {
                return;
            }

            info.IsValid = true;

            for (; ;)
            {
                int marker = 0, prev = 0;

                // find next marker
                for (a = 0; ; ++a)
                {
                    marker = stream.ReadByte();
                    if (marker != JpegId.START && prev == JpegId.START)
                    {
                        break;
                    }
                    prev = marker;
                }

                // read section length
                int lenHigh = stream.ReadByte();
                int lenLow  = stream.ReadByte();
                int itemlen = (lenHigh << 8) | lenLow;

                // read the section
                byte[] section = new byte[itemlen];
                section[0] = (byte)lenHigh;
                section[1] = (byte)lenLow;
                int bytesRead = stream.Read(section, 2, itemlen - 2);
                if (bytesRead != itemlen - 2)
                {
                    return;
                }

                switch (marker)
                {
                case JpegId.SOS:
                    // start of stream: and we're done
                    return;

                case JpegId.EOI:
                    // no data? no good.
                    return;

                case JpegId.EXIF:
                {
                    if (section[2] == 'E' &&
                        section[3] == 'x' &&
                        section[4] == 'i' &&
                        section[5] == 'f')
                    {
                        ProcessExif(section);
                    }
                } break;

                case JpegId.IPTC:
                {
                    // don't care.
                } break;

                case 0xC0:
                case 0xC1:
                case 0xC2:
                case 0xC3:
                // case 0xC4: // not SOF
                case 0xC5:
                case 0xC6:
                case 0xC7:
                // case 0xC8: // not SOF
                case 0xC9:
                case 0xCA:
                case 0xCB:
                // case 0xCC: // not SOF
                case 0xCD:
                case 0xCE:
                case 0xCF:
                {
                    ProcessSOF(section, marker);
                } break;

                default:
                {
                    // don't care.
                } break;
                }

                section = null;
                GC.Collect();
            }
        }
Esempio n. 10
0
 public virtual void Populate(JpegInfo info, ExifIFD ifd)
 {
     if (ifd == ExifIFD.Exif)
     {
         switch ((ExifId)this.Tag)
         {
             case ExifId.ImageWidth: info.Width = GetInt(0); break;
             case ExifId.ImageHeight: info.Height = GetInt(0); break;
             case ExifId.Orientation: info.Orientation = (ExifOrientation)GetInt(0); break;
             case ExifId.XResolution: info.XResolution = GetNumericValue(0); break;
             case ExifId.YResolution: info.YResolution = GetNumericValue(0); break;
             case ExifId.ResolutionUnit: info.ResolutionUnit = (ExifUnit)GetInt(0); break;
             case ExifId.DateTime: info.DateTime = GetStringValue(); break;
             case ExifId.DateTimeOriginal: info.DateTimeOriginal = GetStringValue(); break;
             case ExifId.Description: info.Description = GetStringValue(); break;
             case ExifId.Make: info.Make = GetStringValue(); break;
             case ExifId.Model: info.Model = GetStringValue(); break;
             case ExifId.Software: info.Software = GetStringValue(); break;
             case ExifId.Artist: info.Artist = GetStringValue(); break;
             case ExifId.ThumbnailOffset: info.ThumbnailOffset = GetInt(0); break;
             case ExifId.ThumbnailLength: info.ThumbnailSize = GetInt(0); break;
             case ExifId.Copyright: info.Copyright = GetStringValue(); break;
             case ExifId.UserComment: info.UserComment = GetStringValue(); break;
             case ExifId.ExposureTime: info.ExposureTime = GetNumericValue(0); break;
             case ExifId.FNumber: info.FNumber = GetNumericValue(0); break;
             case ExifId.FlashUsed: info.Flash = (ExifFlash)GetInt(0); break;
             default: break;
         }
     }
     else if (ifd == ExifIFD.Gps)
     {
         switch ((ExifGps)this.Tag)
         {
             case ExifGps.LatitudeRef:
                 {
                     if (GetStringValue() == "N") info.GpsLatitudeRef = ExifGpsLatitudeRef.North;
                     else if (GetStringValue() == "S") info.GpsLatitudeRef = ExifGpsLatitudeRef.South;
                 } break;
             case ExifGps.LongitudeRef:
                 {
                     if (GetStringValue() == "E") info.GpsLongitudeRef = ExifGpsLongitudeRef.East;
                     else if (GetStringValue() == "W") info.GpsLongitudeRef = ExifGpsLongitudeRef.West;
                 } break;
             case ExifGps.Latitude:
                 {
                     if (Components == 3)
                     {
                         info.GpsLatitude[0] = GetNumericValue(0);
                         info.GpsLatitude[1] = GetNumericValue(1);
                         info.GpsLatitude[2] = GetNumericValue(2);
                     }
                 } break;
             case ExifGps.Longitude:
                 {
                     if (Components == 3)
                     {
                         info.GpsLongitude[0] = GetNumericValue(0);
                         info.GpsLongitude[1] = GetNumericValue(1);
                         info.GpsLongitude[2] = GetNumericValue(2);
                     }
                 } break;
         }
     }
 }
Esempio n. 11
0
        public virtual void Populate(JpegInfo info, ExifIFD ifd, long sectionStart)
        {
            if (ifd == ExifIFD.Exif)
            {
                switch ((ExifId)this.Tag)
                {
                case ExifId.FlashUsed:
                    info.Flash = (ExifFlash)this.GetInt(0);
                    break;

                case ExifId.UserComment:
                    info.UserComment = this.GetStringValue();
                    break;

                case ExifId.ExposureTime:
                    info.ExposureTime = this.GetNumericValue(0);
                    break;

                case ExifId.FNumber:
                    info.FNumber = this.GetNumericValue(0);
                    break;

                case ExifId.ThumbnailLength:
                    info.ThumbnailSize = this.GetInt(0);
                    break;

                case ExifId.Copyright:
                    info.Copyright = this.GetStringValue();
                    break;

                case ExifId.Artist:
                    info.Artist = this.GetStringValue();
                    break;

                case ExifId.ThumbnailOffset:
                    info.ThumbnailOffset = this.GetInt(0);
                    break;

                case ExifId.Software:
                    info.Software = this.GetStringValue();
                    break;

                case ExifId.DateTime:
                    info.DateTime = this.GetStringValue();
                    break;

                case ExifId.YResolution:
                    info.YResolution = this.GetNumericValue(0);
                    break;

                case ExifId.ResolutionUnit:
                    info.ResolutionUnit = (ExifUnit)this.GetInt(0);
                    break;

                case ExifId.Description:
                    info.Description = this.GetStringValue();
                    break;

                case ExifId.Make:
                    info.Make = this.GetStringValue();
                    break;

                case ExifId.Model:
                    info.Model = this.GetStringValue();
                    break;

                case ExifId.Orientation:
                    info.OrientationOffset = sectionStart + this.ValueOffset;
                    info.Orientation       = (ExifOrientation)this.GetInt(0);
                    break;

                case ExifId.XResolution:
                    info.XResolution = this.GetNumericValue(0);
                    break;

                case ExifId.ImageWidth:
                    info.Width = this.GetInt(0);
                    break;

                case ExifId.ImageHeight:
                    info.Height = this.GetInt(0);
                    break;
                }
            }
            else
            {
                if (ifd != ExifIFD.Gps)
                {
                    return;
                }
                switch (this.Tag)
                {
                case 1:
                    if (this.GetStringValue() == "N")
                    {
                        info.GpsLatitudeRef = ExifGpsLatitudeRef.North;
                        break;
                    }
                    if (!(this.GetStringValue() == "S"))
                    {
                        break;
                    }
                    info.GpsLatitudeRef = ExifGpsLatitudeRef.South;
                    break;

                case 2:
                    if (this.Components != 3)
                    {
                        break;
                    }
                    info.GpsLatitude[0] = this.GetNumericValue(0);
                    info.GpsLatitude[1] = this.GetNumericValue(1);
                    info.GpsLatitude[2] = this.GetNumericValue(2);
                    break;

                case 3:
                    if (this.GetStringValue() == "E")
                    {
                        info.GpsLongitudeRef = ExifGpsLongitudeRef.East;
                        break;
                    }
                    if (!(this.GetStringValue() == "W"))
                    {
                        break;
                    }
                    info.GpsLongitudeRef = ExifGpsLongitudeRef.West;
                    break;

                case 4:
                    if (this.Components != 3)
                    {
                        break;
                    }
                    info.GpsLongitude[0] = this.GetNumericValue(0);
                    info.GpsLongitude[1] = this.GetNumericValue(1);
                    info.GpsLongitude[2] = this.GetNumericValue(2);
                    break;
                }
            }
        }
Esempio n. 12
0
        public ExifReader(Stream stream)
        {
            this.info = new JpegInfo();
            if (stream.ReadByte() != (int)byte.MaxValue || stream.ReadByte() != 216)
            {
                return;
            }
            this.info.IsValid = true;
            while (true)
            {
                int num1 = 0;
                int num2 = 0;
                int marker;
                while (true)
                {
                    marker = stream.ReadByte();
                    if (marker == (int)byte.MaxValue || num1 != (int)byte.MaxValue)
                    {
                        num1 = marker;
                        ++num2;
                    }
                    else
                    {
                        break;
                    }
                }
                long   position = stream.Position;
                int    num3     = stream.ReadByte();
                int    num4     = stream.ReadByte();
                int    length   = num3 << 8 | num4;
                byte[] numArray = new byte[length];
                numArray[0] = (byte)num3;
                numArray[1] = (byte)num4;
                if (stream.Read(numArray, 2, length - 2) == length - 2)
                {
                    switch (marker)
                    {
                    case 192:
                    case 193:
                    case 194:
                    case 195:
                    case 197:
                    case 198:
                    case 199:
                    case 201:
                    case 202:
                    case 203:
                    case 205:
                    case 206:
                    case 207:
                        this.ProcessSOF(numArray, marker);
                        break;

                    case 217:
                        goto label_10;

                    case 218:
                        goto label_7;

                    case 225:
                        if ((int)numArray[2] == 69 && (int)numArray[3] == 120 && ((int)numArray[4] == 105 && (int)numArray[5] == 102))
                        {
                            this.ProcessExif(numArray, position);
                            break;
                        }
                        break;
                    }
                    GC.Collect();
                }
                else
                {
                    break;
                }
            }
            return;

label_7:
            return;

            label_10 :;
        }
Esempio n. 13
0
        public void ReadExif(JpegInfo info)
        {
            this.seb = info.Width;

        }