1

I'm currently developing an API where it takes a in a video as parameter and then generates a thumbnail from that. When it's later presented with a thumbnail the thumbnail is rotated in the wrong way, i know this has to do with the orientation but i can't seem to find either 0x0112 (274) or 0x5029 (20521) in the PropertyIdList. The only ones i got are 771, 769, 37510, 20753, 20753, 20754. None of these as far as i know are focused on the orientation of the image. I generated the thumbnail with Nreco if that has any connection with it. This is my code thus far:

  if(Array.IndexOf(image.Img.PropertyIdList,20521)>-1)
            {
                var orientation = (int)image.Img.GetPropertyItem(20521).Value[0];
                switch(orientation)
                {
                    case 1:
                        break;
                    case 2:
                        image.Img.RotateFlip(RotateFlipType.RotateNoneFlipX);
                        break;
                    case 3:
                        image.Img.RotateFlip(RotateFlipType.Rotate180FlipNone);
                        break;
                    case 4:
                        image.Img.RotateFlip(RotateFlipType.Rotate180FlipX);
                        break;
                    case 5:
                        image.Img.RotateFlip(RotateFlipType.Rotate90FlipX);
                        break;
                    case 6:
                        image.Img.RotateFlip(RotateFlipType.Rotate90FlipNone);
                        break;
                    case 7:
                        image.Img.RotateFlip(RotateFlipType.Rotate270FlipX);
                        break;
                    case 8:
                        image.Img.RotateFlip(RotateFlipType.Rotate270FlipNone);
                        break;
                }
            }

But it never enters this block of code since it can't find the the indexOf propertyIdList 20521.

Any help would be higly appritiated! Thank you.

EDIT: Video was taken with an Iphone 6

martoo
  • 103
  • 1
  • 9
  • Have you chaecked [this](http://stackoverflow.com/questions/6222053/problem-reading-jpeg-metadata-orientation)? - Maybe the property simply doesn't exist? did you explicitly create it? – TaW May 21 '15 at 09:43
  • Yeah i followed that example before, it begins as a video then i extract a thumbnail from that video with the help of NReco.VideoConverter.FFMpegConverter, that itself creates a thumbnail and saves it into a folder on my disk that i then later retrive and convert that into a bytearray then convert it into a new image and then i try and fix the orientation – martoo May 21 '15 at 09:48
  • Also i don't know if i can explicitly create the orientation correctly without knowing what what i'm recording with the phone – martoo May 21 '15 at 10:14
  • If thumbnail is extracted with NReco.VideoConverter (wrapper for ffmpeg) you may detect orientation from video metadata and perform necessary rotation during thumbnail extraction. – Vitaliy Fedorchenko May 28 '15 at 07:51

0 Answers0