@@ -5,7 +5,8 @@ namespace RagePhoto.Cli;
55
66internal static partial class Commands {
77
8- internal static Int32 CreateFunction ( String format , String ? imageFile , String ? description , String ? json , String ? title , String ? outputFile ) {
8+ internal static Int32 CreateFunction ( String format , String ? imageFile , bool imageAsIs ,
9+ String ? description , String ? json , String ? title , String ? outputFile ) {
910 try {
1011 using Photo photo = new ( ) ;
1112
@@ -28,7 +29,7 @@ internal static Int32 CreateFunction(String format, String? imageFile, String? d
2829 }
2930 else {
3031 using Stream input = imageFile == "-" ? Console . OpenStandardInput ( ) : File . OpenRead ( imageFile ) ;
31- photo . Jpeg = Jpeg . GetJpeg ( input , out size ) ;
32+ photo . Jpeg = Jpeg . GetJpeg ( input , imageAsIs , out size ) ;
3233 }
3334
3435 photo . Json = json == null ?
@@ -147,7 +148,8 @@ internal static Int32 GetFunction(String inputFile, String dataType, String outp
147148 }
148149 }
149150
150- internal static Int32 SetFunction ( String inputFile , String ? format , String ? imageFile , String ? description , String ? json , String ? title , bool updateJson , String ? outputFile ) {
151+ internal static Int32 SetFunction ( String inputFile , String ? format , String ? imageFile , bool imageAsIs ,
152+ String ? description , String ? json , String ? title , bool updateJson , String ? outputFile ) {
151153 try {
152154 if ( format == null && imageFile == null && description == null
153155 && json == null && title == null && ! updateJson ) {
@@ -193,7 +195,7 @@ internal static Int32 SetFunction(String inputFile, String? format, String? imag
193195 }
194196 else if ( imageFile != null ) {
195197 using Stream input = imageFile == "-" ? Console . OpenStandardInput ( ) : File . OpenRead ( imageFile ) ;
196- photo . Jpeg = Jpeg . GetJpeg ( input , out size ) ;
198+ photo . Jpeg = Jpeg . GetJpeg ( input , imageAsIs , out size ) ;
197199 photo . Json = Json . Update ( photo , size , photo . Json , out Int32 uid ) ;
198200 }
199201 else if ( updateJson ) {
@@ -243,6 +245,9 @@ internal static Command CreateCommand {
243245 Option < String ? > imageOption = new ( "--image" , "-i" , "--jpeg" ) {
244246 Description = "Image File"
245247 } ;
248+ Option < bool > imageAsIsOption = new ( "--image-as-is" ) {
249+ Description = "Image as-is"
250+ } ;
246251 Option < String ? > descriptionOption = new ( "--description" , "-d" ) {
247252 Description = "Description"
248253 } ;
@@ -256,11 +261,18 @@ internal static Command CreateCommand {
256261 Description = "Output File"
257262 } ;
258263 Command createCommand = new ( "create" , "Create a new Photo" ) {
259- formatArgument , imageOption , descriptionOption , jsonOption , titleOption , outputOption
264+ formatArgument ,
265+ imageOption ,
266+ imageAsIsOption ,
267+ descriptionOption ,
268+ jsonOption ,
269+ titleOption ,
270+ outputOption
260271 } ;
261272 createCommand . SetAction ( result => Environment . ExitCode = CreateFunction (
262273 result . GetRequiredValue ( formatArgument ) ,
263274 result . GetValue ( imageOption ) ,
275+ result . GetValue ( imageAsIsOption ) ,
264276 result . GetValue ( descriptionOption ) ,
265277 result . GetValue ( jsonOption ) ,
266278 result . GetValue ( titleOption ) ,
@@ -302,7 +314,9 @@ internal static Command GetCommand {
302314 DefaultValueFactory = _ => "-"
303315 } ;
304316 Command getCommand = new ( "get" , "Get Data from a Photo" ) {
305- inputArgument , typeArgument , outputOption
317+ inputArgument ,
318+ typeArgument ,
319+ outputOption
306320 } ;
307321 getCommand . SetAction ( result => Environment . ExitCode = GetFunction (
308322 result . GetRequiredValue ( inputArgument ) ,
@@ -323,6 +337,9 @@ internal static Command SetCommand {
323337 Option < String ? > imageOption = new ( "--image" , "-i" , "--jpeg" ) {
324338 Description = "Image File"
325339 } ;
340+ Option < bool > imageAsIsOption = new ( "--image-as-is" ) {
341+ Description = "Image as-is"
342+ } ;
326343 Option < String ? > descriptionOption = new ( "--description" , "-d" ) {
327344 Description = "Description"
328345 } ;
@@ -339,12 +356,21 @@ internal static Command SetCommand {
339356 Description = "Output File"
340357 } ;
341358 Command setCommand = new ( "set" , "Set Data from a Photo" ) {
342- inputArgument , formatOption , imageOption , descriptionOption , jsonOption , titleOption , updateJsonOption , outputOption
359+ inputArgument ,
360+ formatOption ,
361+ imageOption ,
362+ imageAsIsOption ,
363+ descriptionOption ,
364+ jsonOption ,
365+ titleOption ,
366+ updateJsonOption ,
367+ outputOption
343368 } ;
344369 setCommand . SetAction ( result => Environment . ExitCode = SetFunction (
345370 result . GetRequiredValue ( inputArgument ) ,
346371 result . GetValue ( formatOption ) ,
347372 result . GetValue ( imageOption ) ,
373+ result . GetValue ( imageAsIsOption ) ,
348374 result . GetValue ( descriptionOption ) ,
349375 result . GetValue ( jsonOption ) ,
350376 result . GetValue ( titleOption ) ,
0 commit comments