Completed
Push — 0716 ( 9f6cba...7ab19d )
by Mikael
03:07
created

webroot/img_config.php (6 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Configuration for img.php, name the config file the same as your img.php and
4
 * append _config. If you are testing out some in imgtest.php then label that
5
 * config-file imgtest_config.php.
6
 *
7
 */
8
9
10
11
/**
12
 * Change to true to enable debug mode which logs additional information
13
 * to file. Only use for test and development. You must create the logfile
14
 * and make it writable by the webserver or log entries will silently fail.
15
 *
16
 * CIMAGE_DEBUG will be false by default, if its not defined.
17
 */
18
if (!defined("CIMAGE_DEBUG")) {
19
    define("CIMAGE_DEBUG", false);
20
    //define("CIMAGE_DEBUG", true);
21
    define("CIMAGE_DEBUG_FILE", "/tmp/cimage");
22
}
23
24
25
26
return array(
27
28
    /**
29
     * Set mode as 'strict', 'production' or 'development'.
30
     *
31
     * development: Development mode with verbose error reporting. Option
32
     *              &verbose and &status enabled.
33
     * production:  Production mode logs all errors to file, giving server
34
     *              error 500 for bad usage. Option &verbose and &status
35
     *              disabled.
36
     * strict:      Strict mode logs few errors to file, giving server error
37
     *              500 for bad usage. Stripped from comments and spaces.
38
     *              Option &verbose and &status disabled.
39
     *
40
     * Default values:
41
     *  mode: 'production'
42
     */
43
     //'mode' => 'production',
44
     //'mode' => 'development',
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
45
     //'mode' => 'strict',
46
47
48
49
    /**
50
     * Where to find the autoloader.
51
     *
52
     * Default values:
53
     *  autoloader:  null
54
     */
55
    'autoloader'   =>  __DIR__ . '/../autoload.php',
56
57
58
59
    /**
60
     * Paths, where are the images stored and where is the cache.
61
     * End all paths with a slash.
62
     *
63
     * Default values:
64
     *  image_path:     __DIR__ . '/img/'
65
     *  cache_path:     __DIR__ . '/../cache/'
66
     *  alias_path:     null
67
     */
68
    'image_path'        =>  __DIR__ . '/img/',
69
    'cache_path'        =>  __DIR__ . '/../cache/',
70
    //'alias_path'   =>  __DIR__ . '/img/alias/',
71
72
73
74
    /**
75
     * Fast track cache. Save a json representation of the image as a
76
     * fast track to the cached version of the image. This avoids some
77
     * processing and allows for quicker load times of cached images.
78
     *
79
     * Default values:
80
     *  fast_track_allow: false
81
     */
82
    //'fast_track_allow' => true,
83
84
85
86
    /**
87
     * Class names to use, to ease dependency injection. You can change Class
88
     * name if you want to use your own class instead. This is a way to extend
89
     * the codebase.
90
     *
91
     * Default values:
92
     *  CImage: CImage
93
     *  CCache: CCache
94
     *  CFastTrackCache: CFastTrackCache
95
     */
96
     //'CImage' => 'CImage',
97
     //'CCache' => 'CCache',
98
     //'CFastTrackCache' => 'CFastTrackCache',
99
100
101
102
    /**
103
     * Use password to protect from missusage, send &pwd=... or &password=..
104
     * with the request to match the password or set to false to disable.
105
     * Passwords are only used together with options for remote download
106
     * and aliasing.
107
     *
108
     * Create a passwords like this, depending on the type used:
109
     *  text: 'my_password'
110
     *  md5:  md5('my_password')
111
     *  hash: password_hash('my_password', PASSWORD_DEFAULT)
112
     *
113
     * Default values.
114
     *  password_always: false  // do not always require password,
115
     *  password:        false  // as in do not use password
116
     *  password_type:   'text' // use plain password, not encoded,
117
     */
118
    //'password_always' => false, // always require password,
119
    //'password'        => false, // "secret-password",
120
    //'password_type'   => 'text', // supports 'text', 'md5', 'hash',
121
122
123
124
    /**
125
     * Allow or disallow downloading of remote images available on
126
     * remote servers. Default is to disallow remote download.
127
     *
128
     * When enabling remote download, the default is to allow download any
129
     * link starting with http or https. This can be changed using
130
     * remote_pattern.
131
     *
132
     * When enabling remote_whitelist a check is made that the hostname of the
133
     * source to download matches the whitelist. By default the check is
134
     * disabled and thereby allowing download from any hosts.
135
     *
136
     * Default values.
137
     *  remote_allow:     false
138
     *  remote_pattern:   null  // use default values from CImage which is to
139
     *                          // allow download from any http- and
140
     *                          // https-source.
141
     *  remote_whitelist: null  // use default values from CImage which is to
142
     *                          // allow download from any hosts.
143
     */
144
    //'remote_allow'     => true,
145
    //'remote_pattern'   => '#^https?://#',
146
    //'remote_whitelist' => array(
147
    //    '\.facebook\.com$',
148
    //    '^(?:images|photos-[a-z])\.ak\.instagram\.com$',
149
    //    '\.google\.com$'
150
    //),
151
152
153
154
    /**
155
     * Use backup image if src-image is not found on disk. The backup image
156
     * is only available for local images and based on wether the original
157
     * image is found on disk or not. The backup image must be a local image
158
     * or the dummy image.
159
     *
160
     * Default value:
161
     *  src_alt:  null //disabled by default
162
     */
163
     //'src_alt' => 'car.png',
164
     //'src_alt' => 'dummy',
165
166
167
168
    /**
169
     * A regexp for validating characters in the image or alias filename.
170
     *
171
     * Default value:
172
     *  valid_filename:  '#^[a-z0-9A-Z-/_ \.:]+$#'
173
     *  valid_aliasname: '#^[a-z0-9A-Z-_]+$#'
174
     */
175
     //'valid_filename'  => '#^[a-z0-9A-Z-/_ \.:]+$#',
176
     //'valid_aliasname' => '#^[a-z0-9A-Z-_]+$#',
177
178
179
180
     /**
181
      * Change the default values for CImage quality and compression used
182
      * when saving images.
183
      *
184
      * Default value:
185
      *  jpg_quality:     null, integer between 0-100
186
      *  png_compression: null, integer between 0-9
187
      */
188
      //'jpg_quality'  => 75,
189
      //'png_compression' => 1,
190
191
192
193
      /**
194
       * Convert the image to srgb before processing. Saves the converted
195
       * image in a cache subdir 'srgb'. This option is default false but can
196
       * be changed to default true to do this conversion for all images.
197
       * This option requires PHP extension imagick and will silently fail
198
       * if that is not installed.
199
       *
200
       * Default value:
201
       *  srgb_default:      false
202
       *  srgb_colorprofile: __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc'
203
       */
204
       //'srgb_default' => false,
205
       //'srgb_colorprofile' => __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc',
206
207
208
209
       /**
210
        * Set skip-original to true to always process the image and use
211
        * the cached version. Default is false and to use the original
212
        * image when its no processing needed.
213
        *
214
        * Default value:
215
        *  skip_original: false
216
        */
217
        //'skip_original' => true,
218
219
220
221
      /**
222
       * A function (hook) can be called after img.php has processed all
223
       * configuration options and before processing the image using CImage.
224
       * The function receives the $img variabel and an array with the
225
       * majority of current settings.
226
       *
227
       * Default value:
228
       *  hook_before_CImage:     null
229
       */
230
       /*'hook_before_CImage' => function (CImage $img, Array $allConfig) {
231
           if ($allConfig['newWidth'] > 10) {
232
               $allConfig['newWidth'] *= 2;
233
           }
234
           return $allConfig;
235
       },*/
236
237
238
239
       /**
240
        * Add header for cache control when outputting images.
241
        *
242
        * Default value:
243
        *  cache_control: null, or set to string
244
        */
245
        //'cache_control' => "max-age=86400",
246
247
248
249
     /**
250
      * The name representing a dummy image which is automatically created
251
      * and stored as a image in the dir CACHE_PATH/dummy. The dummy image
252
      * can then be used as a placeholder image.
253
      * The dir CACHE_PATH/dummy is automatically created when needed.
254
      * Write protect the CACHE_PATH/dummy to prevent creation of new
255
      * dummy images, but continue to use the existing ones.
256
      *
257
      * Default value:
258
      *  dummy_enabled:  true as default, disable dummy feature by setting
259
      *                  to false.
260
      *  dummy_filename: 'dummy' use this as ?src=dummy to create a dummy image.
261
      */
262
      //'dummy_enabled' => true,
263
      //'dummy_filename' => 'dummy',
264
265
266
267
     /**
268
     * Check that the imagefile is a file below 'image_path' using realpath().
269
     * Security constraint to avoid reaching images outside image_path.
270
     * This means that symbolic links to images outside the image_path will
271
     * fail.
272
     *
273
     * Default value:
274
     *  image_path_constraint: true
275
     */
276
     //'image_path_constraint' => false,
277
278
279
280
     /**
281
     * Set default timezone.
282
     *
283
     * Default values.
284
     *  default_timezone: ini_get('default_timezone') or 'UTC'
285
     */
286
    //'default_timezone' => 'UTC',
287
288
289
290
    /**
291
     * Max image dimensions, larger dimensions results in 404.
292
     * This is basically a security constraint to avoid using resources on creating
293
     * large (unwanted) images.
294
     *
295
     * Default values.
296
     *  max_width:  2000
297
     *  max_height: 2000
298
     */
299
    //'max_width'     => 2000,
300
    //'max_height'    => 2000,
301
302
303
304
    /**
305
     * Set default background color for all images. Override it using
306
     * option bgColor.
307
     * Colorvalue is 6 digit hex string between 000000-FFFFFF
308
     * or 8 digit hex string if using the alpha channel where
309
     * the alpha value is between 00 (opaqe) and 7F (transparent),
310
     * that is between 00000000-FFFFFF7F.
311
     *
312
     * Default values.
313
     *  background_color: As specified by CImage
314
     */
315
    //'background_color' => "FFFFFF",
316
    //'background_color' => "FFFFFF7F",
317
318
319
320
    /**
321
     * Post processing of images using external tools, set to true or false
322
     * and set command to be executed.
323
     *
324
     * The png_lossy can alos have a value of null which means that its
325
     * enabled but not used as default. Each image having the option
326
     * &lossy will be processed. This means one can individually choose
327
     * when to use the lossy processing.
328
     *
329
     * Default values.
330
     *
331
     *  png_lossy:        false
332
     *  png_lossy_cmd:    '/usr/local/bin/pngquant --force --output'
333
     *
334
     *  png_filter:        false
335
     *  png_filter_cmd:    '/usr/local/bin/optipng -q'
336
     *
337
     *  png_deflate:       false
338
     *  png_deflate_cmd:   '/usr/local/bin/pngout -q'
339
     *
340
     *  jpeg_optimize:     false
341
     *  jpeg_optimize_cmd: '/usr/local/bin/jpegtran -copy none -optimize'
342
     */
343
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
344
    'postprocessing' => array(
345
        'png_lossy'       => false,
346
        'png_lossy_cmd'   => '/usr/local/bin/pngquant --force --output',
347
348
        'png_filter'        => false,
349
        'png_filter_cmd'    => '/usr/local/bin/optipng -q',
350
351
        'png_deflate'       => false,
352
        'png_deflate_cmd'   => '/usr/local/bin/pngout -q',
353
354
        'jpeg_optimize'     => false,
355
        'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',
356
    ),
357
    */
358
359
360
361
    /**
362
     * Create custom convolution expressions, matrix 3x3, divisor and
363
     * offset.
364
     *
365
     * Default values.
366
     *  convolution_constant: array()
367
     */
368
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
369
    'convolution_constant' => array(
370
        //'sharpen'       => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',
371
        //'sharpen-alt'   => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',
372
    ),
373
    */
374
375
376
377
    /**
378
     * Prevent leeching of images by controlling the hostname of those who
379
     * can access the images. Default is to allow hotlinking.
380
     *
381
     * Password apply when hotlinking is disallowed, use password to allow
382
     * hotlinking.
383
     *
384
     * The whitelist is an array of regexpes for allowed hostnames that can
385
     * hotlink images.
386
     *
387
     * Default values.
388
     *  allow_hotlinking:     true
389
     *  hotlinking_whitelist: array()
390
     */
391
     /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
392
    'allow_hotlinking' => false,
393
    'hotlinking_whitelist' => array(
394
        '^dbwebb\.se$',
395
    ),
396
    */
397
398
399
    /**
400
     * Create custom shortcuts for more advanced expressions.
401
     *
402
     * Default values.
403
     *  shortcut: array(
404
     *      'sepia' => "&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen",
405
     *  )
406
     */
407
     /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
408
    'shortcut' => array(
409
        'sepia' => "&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen",
410
    ),*/
411
412
413
414
    /**
415
     * Predefined size constants.
416
     *
417
     * These can be used together with &width or &height to create a constant value
418
     * for a width or height where can be changed in one place.
419
     * Useful when your site changes its layout or if you have a grid to fit images into.
420
     *
421
     * Example:
422
     *  &width=w1  // results in width=613
423
     *  &width=c2  // results in spanning two columns with a gutter, 30*2+10=70
424
     *  &width=c24 // results in spanning whole grid 24*30+((24-1)*10)=950
425
     *
426
     * Default values.
427
     *  size_constant: As specified by the function below.
428
     */
429
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
37% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
430
    'size_constant' => function () {
431
432
        // Set sizes to map constant to value, easier to use with width or height
433
        $sizes = array(
434
          'w1' => 613,
435
          'w2' => 630,
436
        );
437
438
        // Add grid column width, useful for use as predefined size for width (or height).
439
        $gridColumnWidth = 30;
440
        $gridGutterWidth = 10;
441
        $gridColumns     = 24;
442
443
        for ($i = 1; $i <= $gridColumns; $i++) {
444
            $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;
445
        }
446
447
        return $sizes;
448
    },*/
449
450
451
452
    /**
453
     * Predefined aspect ratios.
454
     *
455
     * Default values.
456
     *  aspect_ratio_constant: As the function below.
457
     */
458
    /*'aspect_ratio_constant' => function () {
459
        return array(
460
            '3:1'   => 3/1,
461
            '3:2'   => 3/2,
462
            '4:3'   => 4/3,
463
            '8:5'   => 8/5,
464
            '16:10' => 16/10,
465
            '16:9'  => 16/9,
466
            'golden' => 1.618,
467
        );
468
    },*/
469
470
471
472
    /**
473
     * Default options for ascii image.
474
     *
475
     * Default values as specified below in the array.
476
     *  ascii-options:
477
     *   characterSet:       Choose any character set available in CAsciiArt.
478
     *   scale:              How many pixels should each character
479
     *                       translate to.
480
     *   luminanceStrategy:  Choose any strategy available in CAsciiArt.
481
     *   customCharacterSet: Define your own character set.
482
     */
483
    /*'ascii-options' => array(
484
            "characterSet" => 'two',
485
            "scale" => 14,
486
            "luminanceStrategy" => 3,
487
            "customCharacterSet" => null,
488
        );
489
    },*/
490
);
491