11
2- /* Metadata Removal Tool v3.2.8 for windows. Compile using gcc c complier mingw only*/
2+ /* Metadata Removal Tool v3.5.0 for windows. Compile using gcc c complier mingw only*/
33//[ THIS IS A STABLE RELEASE]
44
55#include <string.h>
66#include <stdio.h>
77#include <stdlib.h>
8+ #include <ctype.h>
9+ #include <stdbool.h>
810
911char file [80 ],vfile [80 ],fil [50 ],vfil [50 ];
1012
@@ -20,10 +22,11 @@ void pause()
2022void checker ()
2123 {
2224 int check = 0 ;
23- char eff [80 ];
25+ char eff [80 ];
2426 memcpy (eff ,"exiftool " ,10 );eff [9 ]= '\0' ;
2527 strcat (eff ,file );
2628 strcat (eff ,">output.txt" );
29+
2730 check = system (eff );
2831 if (check != 0 )
2932 {
@@ -55,41 +58,78 @@ void vchecker()
5558 }
5659
5760//Function to get input from user.
58- void input ()
61+ void input ()
5962 {
6063 system ("cls" );
6164 printf ("\n\t|---------Image Sanitisation Tool ---------|\n" );
6265 printf ("\n\n Enter Image name:" );
6366 scanf ("%30s" ,fil );
64- memcpy (file ,"Images\\" ,9 );file [8 ]= '\0' ;
67+ memcpy (file ,"Images\\" ,8 );file [8 ]= '\0' ;
6568 strcat (file ,fil );
6669 }
6770
71+ bool endswith (const char str1 [] , const char str2 [] )
72+ {
73+ int i = 0 ;
74+ int j = 0 ;
75+ int str1_length = strlen (str1 );
76+ int str2_length = strlen (str2 );
77+ if (str1_length > str2_length )
78+ {
79+ for (i = str2_length - 1 ,j = str1_length - 1 ; i >=0 ;-- j ,-- i )
80+ {
81+ if (tolower (str1 [j ])!= tolower (str2 [i ]))
82+ {
83+ return false;
84+ }
85+ }
86+ return true;
87+ }
88+ return false;
89+
90+ }
91+
6892//Function to sanitize the image selected using exiftool.
6993void sanitize ()
7094 {
7195 int check = 0 ;
96+ int file_length = 0 ;
97+ int visit = 0 ;
7298 char eff [80 ];
73- memcpy (eff ,"exiftool " ,10 );eff [9 ]= '\0' ;
74- strcat (eff ,file );
75- strcat (eff ," -all=" );
76- check = system (eff );
99+ char tmp [80 ];
100+ file_length = strlen (file );
101+
102+ if ( endswith (file ,"tiff" ) || endswith (file ,"tif" ))
103+ {
104+ memcpy (tmp ,"exiftool -all= -CommonIFD0= " ,28 );tmp [28 ] = '\0' ;
105+ strcat (tmp ,file );
106+ check = system (tmp );
107+ visit = 1 ;
108+ }
109+
110+ else if (visit == 0 ){
111+ memcpy (eff ,"exiftool " ,10 );eff [9 ]= '\0' ;
112+ strcat (eff ,file );
113+ strcat (eff ," -all=" );
114+ check = system (eff );
115+ }
77116 if (check != 0 )
78117 {
79118 printf ("\n\nImage Sanitization failed maybe exiftool is missing!\nor Something went wrong like you entering a non image file!" );
80119 system ("start https://exiftool.org" );
81120 pause ();
82121 exit (0 );
83122 }
123+
84124 }
85125
86126//Function to generate and check generation of input log.
87- void ichecker ()
127+ void ichecker ()
88128 {
89- int check = 0 ;
90- char eff [80 ];
91- memcpy (eff ,"exiftool " ,10 );eff [9 ]= '\0' ;
92- strcat (eff ,file );
129+ int check = 0 ;
130+ char eff [80 ];
131+ memcpy (eff ,"exiftool " ,10 );eff [9 ]= '\0' ;
132+ strcat (eff ,file );
93133 strcat (eff ,">input.txt" );
94134 check = system (eff );
95135 if (check != 0 )
@@ -103,12 +143,12 @@ void sanitize()
103143
104144
105145 //Function to generate and check generation of input log for videos.
106- void ivchecker ()
146+ void ivchecker ()
107147 {
108- int check = 0 ;
109- char eff [200 ];
110- memcpy (eff ,"exiftool " ,10 );eff [9 ]= '\0' ;
111- strcat (eff ,vfile );
148+ int check = 0 ;
149+ char eff [200 ];
150+ memcpy (eff ,"exiftool " ,10 );eff [9 ]= '\0' ;
151+ strcat (eff ,vfile );
112152 strcat (eff ,">video_input_metadata.txt" );
113153 check = system (eff );
114154 if (check != 0 )
@@ -121,18 +161,19 @@ void sanitize()
121161 }
122162
123163//Function to add support for * wildcards.
124- void detect ()
164+ void detect ()
125165 {
126166 FILE * f ;
127167 char d ;
128168 int flag = 0 ,len = 0 ,i = 0 ;
129- for ( i = 0 ;i < strlen (file );i ++ )
169+ int file_length = strlen (file );
170+ for ( i = 0 ;i < file_length ;i ++ )
130171 {
131172 if ((file [i ]== '.' )&& (i > 0 ))
132173 {
133174 if (file [i - 1 ]== '*' )
134175 {
135- if (((strlen ( file ) - i )== 4 )|| ((strlen ( file ) - i )== 5 ))
176+ if (((file_length - i )== 4 )|| ((file_length - i )== 5 ))
136177 {
137178 flag = 1 ;
138179 }
@@ -151,7 +192,7 @@ void sanitize()
151192 }}
152193
153194//Function to check if image file was cleaned successfully by comparing size of input log and output log files generated by exiftool.
154- void compare ()
195+ void compare ()
155196 {
156197 FILE * a ,* b ;
157198 int w1 = 0 ,w2 = 0 ;
@@ -181,7 +222,8 @@ void sanitize()
181222 }
182223fclose (a );fclose (b );
183224 }
184- void run () // combine all functions .
225+
226+ void run () // combine all functions .
185227 {
186228 input ();
187229 detect ();
@@ -191,16 +233,18 @@ fclose(a);fclose(b);
191233 compare ();
192234 pause ();
193235 }
194- void vinput ()
236+
237+ void vinput ()
195238{
196239 /* Gets input ( filename ) for removal of metadata from videos*/
197240 system ("cls" );
198241 printf ("\n\t |----- Video sanitisation tool -----|\n" );
199242 printf ("\n\n Enter Video name:" );
200243 scanf ("%30s" ,vfil );
201- memcpy (vfile ,"Videos\\" ,9 );vfile [8 ]= '\0' ;
244+ memcpy (vfile ,"Videos\\" ,8 );vfile [8 ]= '\0' ;
202245 strcat (vfile ,vfil );
203246}
247+
204248void vdetect ()
205249 {
206250 /* Detects if video file is present or not.*/
@@ -234,6 +278,7 @@ void vtool()
234278 fclose (f );
235279
236280}
281+
237282void vsanitise ()
238283{
239284 /* Actual metadata removal process happens here.*/
@@ -252,6 +297,7 @@ void vsanitise()
252297 }
253298
254299}
300+
255301void qrun ()
256302{
257303 /* Responsible for combining all video management functions.*/
@@ -263,7 +309,8 @@ void qrun()
263309 vchecker ();
264310 pause ();
265311}
266- void menu ()
312+
313+ void menu ()
267314{
268315 int raw = 0 ,backdoor = 0 ;
269316 printf ("\n\t|----- Menu -----|\n\n" );
@@ -292,9 +339,9 @@ void qrun()
292339 }
293340}
294341
295- void main ()
342+ void main ()
296343 {
297- system ("title Metadata Removal Tool v3.2.2 " );
344+ system ("title Metadata Removal Tool v3.5.0 " );
298345 menu ();
299346 }
300347
0 commit comments