00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <magick/MagickCore.h>
00019
00020
00021 #include "imageMS.h"
00022 #include "imageMSutil.h"
00023 #include "rsApiHandler.h"
00024 #include "apiHeaderAll.h"
00025 #include "fileLseek.h"
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 int
00080 msiImageConvert( msParam_t *sourceParam, msParam_t* sourceProp,
00081 msParam_t *destParam, msParam_t *destProp, ruleExecInfo_t *rei )
00082 {
00083 rsComm_t *rsComm = NULL;
00084 char* format = NULL;
00085
00086 ImageFileParameter_t source;
00087 ImageFileParameter_t destination;
00088
00089 dataObjInp_t sourceObject;
00090 dataObjInp_t destinationObject;
00091
00092 source.dataObject = &sourceObject;
00093 destination.dataObject = &destinationObject;
00094
00095
00096 RE_TEST_MACRO( " Calling msiImageConvert" );
00097
00098
00099
00100
00101
00102
00103
00104
00105 if ( rei == NULL || rei->rsComm == NULL )
00106 {
00107 rodsLog( LOG_ERROR, "msiImageConvert: input rei or rsComm is NULL" );
00108 return SYS_INTERNAL_NULL_INPUT_ERR;
00109 }
00110 rsComm = rei->rsComm;
00111
00112 if ( (rei->status = _ImageGetFileParameter( rsComm, "msiImageConvert: source file",
00113 sourceParam, &source )) < 0 )
00114 return rei->status;
00115
00116 source.properties = (keyValPair_t*)mallocAndZero( sizeof( keyValPair_t ) );
00117 if ( (rei->status = _ImageGetPropertyListParameter( rsComm, "msiImageConvert: source properties",
00118 sourceProp, &(source.properties) )) < 0 )
00119 {
00120 free( (char*)source.properties );
00121 return rei->status;
00122 }
00123
00124 if ( (rei->status = _ImageGetFileParameter( rsComm, "msiImageConvert: destination file",
00125 destParam, &destination )) < 0 )
00126 {
00127 free( (char*)source.properties );
00128 return rei->status;
00129 }
00130
00131 destination.properties = (keyValPair_t*)mallocAndZero( sizeof( keyValPair_t ) );
00132 if ( (rei->status = _ImageGetPropertyListParameter( rsComm, "msiImageConvert: destination properties",
00133 destProp, &(destination.properties) )) < 0 )
00134 {
00135 free( (char*)source.properties );
00136 free( (char*)destination.properties );
00137 return rei->status;
00138 }
00139
00140
00141
00142
00143
00144 MagickCoreGenesis( "", MagickFalse );
00145
00146
00147
00148
00149
00150
00151
00152 rei->status = _ImageReadFile( rsComm, "msiImageConvert: source file",
00153 &source );
00154 if ( rei->status >= 0 )
00155 {
00156
00157 destination.image = source.image;
00158 rei->status = _ImageWriteFile( rsComm, "msiImageConvert: destination file",
00159 &destination );
00160 }
00161
00162
00163
00164
00165
00166 if ( source.image != NULL )
00167 DestroyImage( source.image );
00168 MagickCoreTerminus( );
00169
00170 free( (char*)source.properties );
00171 free( (char*)destination.properties );
00172 return rei->status;
00173
00174 }
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 int
00217 msiImageGetProperties( msParam_t *sourceParam, msParam_t* sourceProp,
00218 msParam_t *listParam, ruleExecInfo_t *rei )
00219 {
00220 rsComm_t *rsComm = NULL;
00221 ImageFileParameter_t source;
00222 dataObjInp_t sourceObject;
00223 keyValPair_t* list = NULL;
00224
00225 source.dataObject = &sourceObject;
00226
00227
00228 RE_TEST_MACRO( " Calling msiImageGetProperties" );
00229
00230
00231
00232
00233
00234
00235
00236 if ( rei == NULL || rei->rsComm == NULL )
00237 {
00238 rodsLog( LOG_ERROR,
00239 "msiImageGetProperties: input rei or rsComm is NULL" );
00240 return SYS_INTERNAL_NULL_INPUT_ERR;
00241 }
00242 rsComm = rei->rsComm;
00243
00244 if ( (rei->status = _ImageGetFileParameter( rsComm, "msiImageGetProperties: source file",
00245 sourceParam, &source )) < 0 )
00246 return rei->status;
00247
00248 source.properties = (keyValPair_t*)mallocAndZero( sizeof( keyValPair_t ) );
00249 if ( (rei->status = _ImageGetPropertyListParameter( rsComm, "msiImageGetProperties: source properties",
00250 sourceProp, &(source.properties) )) < 0 )
00251 {
00252 free( (char*)source.properties );
00253 return rei->status;
00254 }
00255
00256
00257
00258
00259
00260
00261 list = (keyValPair_t*)mallocAndZero( sizeof(keyValPair_t) );
00262 fillMsParam( listParam, NULL, KeyValPair_MS_T, list, NULL );
00263 if ( source.type == IMAGEFILEPARAMETER_PATH )
00264 {
00265
00266 addKeyVal( list, "file.Name", source.path );
00267 }
00268
00269
00270
00271
00272
00273 MagickCoreGenesis( "", MagickFalse );
00274
00275
00276
00277
00278
00279
00280
00281 rei->status = _ImageReadFile( rsComm, "msiImageGetProperties: source file",
00282 &source );
00283 if ( rei->status >= 0 )
00284 {
00285
00286 rei->status = _ImageGetProperties( &source, list );
00287 }
00288
00289
00290
00291
00292
00293 if ( source.image != NULL )
00294 DestroyImage( source.image );
00295 MagickCoreTerminus( );
00296
00297 return rei->status;
00298 }
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357 int
00358 msiImageScale( msParam_t* sourceParam, msParam_t* sourceProp,
00359 msParam_t* xScaleFactor, msParam_t* yScaleFactor,
00360 msParam_t* destParam, msParam_t* destProp, ruleExecInfo_t* rei )
00361 {
00362 rsComm_t *rsComm = NULL;
00363 char* format = NULL;
00364
00365 ImageFileParameter_t source;
00366 ImageFileParameter_t destination;
00367
00368 double xScale = 1.0;
00369 double yScale = 1.0;
00370
00371 dataObjInp_t sourceObject;
00372 dataObjInp_t destinationObject;
00373
00374 source.dataObject = &sourceObject;
00375 destination.dataObject = &destinationObject;
00376
00377
00378 RE_TEST_MACRO( " Calling msiImageScale" );
00379
00380
00381
00382
00383
00384
00385
00386
00387 if ( rei == NULL || rei->rsComm == NULL )
00388 {
00389 rodsLog( LOG_ERROR, "msiImageScale: input rei or rsComm is NULL" );
00390 return SYS_INTERNAL_NULL_INPUT_ERR;
00391 }
00392 rsComm = rei->rsComm;
00393
00394 if ( (rei->status = _ImageGetFileParameter( rsComm, "msiImageScale: source file",
00395 sourceParam, &source )) < 0 )
00396 return rei->status;
00397
00398 source.properties = (keyValPair_t*)mallocAndZero( sizeof( keyValPair_t ) );
00399 if ( (rei->status = _ImageGetPropertyListParameter( rsComm, "msiImageScale: source properties",
00400 sourceProp, &(source.properties) )) < 0 )
00401 {
00402 free( (char*)source.properties );
00403 return rei->status;
00404 }
00405
00406 if ( (rei->status = _ImageGetDouble( rsComm, "msiImageScale: source X scale",
00407 xScaleFactor, &xScale )) < 0 )
00408 {
00409 free( (char*)source.properties );
00410 return rei->status;
00411 }
00412
00413 if ( (rei->status = _ImageGetDouble( rsComm, "msiImageScale: source Y scale",
00414 yScaleFactor, &yScale )) < 0 )
00415 {
00416 free( (char*)source.properties );
00417 return rei->status;
00418 }
00419
00420 if ( (rei->status = _ImageGetFileParameter( rsComm, "msiImageScale: destination file",
00421 destParam, &destination )) < 0 )
00422 {
00423 free( (char*)source.properties );
00424 return rei->status;
00425 }
00426
00427 destination.properties = (keyValPair_t*)mallocAndZero( sizeof( keyValPair_t ) );
00428 if ( (rei->status = _ImageGetPropertyListParameter( rsComm, "msiImageScale: destination properties",
00429 destProp, &(destination.properties) )) < 0 )
00430 {
00431 free( (char*)source.properties );
00432 free( (char*)destination.properties );
00433 return rei->status;
00434 }
00435
00436
00437
00438
00439
00440 MagickCoreGenesis( "", MagickFalse );
00441
00442
00443
00444
00445
00446
00447
00448 rei->status = _ImageReadFile( rsComm, "msiImageScale: source file",
00449 &source );
00450 if ( rei->status >= 0 )
00451 {
00452
00453
00454
00455 destination.image = source.image;
00456 rei->status = _ImageWriteFile( rsComm, "msiImageScale: destination file",
00457 &destination );
00458 }
00459
00460
00461
00462
00463
00464 if ( source.image != NULL )
00465 DestroyImage( source.image );
00466 MagickCoreTerminus( );
00467
00468 free( (char*)source.properties );
00469 free( (char*)destination.properties );
00470 return rei->status;
00471 }
00472