a4a60f3baa245fb9c081bb62d340cde1470f731a
[platform/upstream/gstreamer.git] / gst-libs / gst / tag / gsttageditingprivate.c
1 /* GStreamer
2  * Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include "gsttageditingprivate.h"
21
22 #include <string.h>
23
24 gint
25 gst_tag_image_orientation_to_exif_value (const gchar * str)
26 {
27   if (str == NULL)
28     goto end;
29
30   if (strcmp (str, "rotate-0") == 0)
31     return 1;
32   else if (strcmp (str, "flip-rotate-0") == 0)
33     return 2;
34   else if (strcmp (str, "rotate-180") == 0)
35     return 3;
36   else if (strcmp (str, "flip-rotate-180") == 0)
37     return 4;
38   else if (strcmp (str, "flip-rotate-270") == 0)
39     return 5;
40   else if (strcmp (str, "rotate-90") == 0)
41     return 6;
42   else if (strcmp (str, "flip-rotate-90") == 0)
43     return 7;
44   else if (strcmp (str, "rotate-270") == 0)
45     return 8;
46
47 end:
48   GST_WARNING ("Invalid image orientation tag: %s", str);
49   return -1;
50 }
51
52 const gchar *
53 gst_tag_image_orientation_from_exif_value (gint value)
54 {
55   switch (value) {
56     case 1:
57       return "rotate-0";
58     case 2:
59       return "flip-rotate-0";
60     case 3:
61       return "rotate-180";
62     case 4:
63       return "flip-rotate-180";
64     case 5:
65       return "flip-rotate-270";
66     case 6:
67       return "rotate-90";
68     case 7:
69       return "flip-rotate-90";
70     case 8:
71       return "rotate-270";
72     default:
73       GST_WARNING ("Invalid tiff orientation tag value: %d", value);
74       return NULL;
75   }
76 }