Completed
Push — 0713 ( c637fa...b1d0cb )
by Mikael
02:55
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
return array(
9
10
    /**
11
     * Set mode as 'strict', 'production' or 'development'.
12
     *
13
     * development: Development mode with verbose error reporting. Option
14
     *              &verbose and &status enabled.
15
     * production:  Production mode logs all errors to file, giving server
16
     *              error 500 for bad usage. Option &verbose and &status
17
     *              disabled.
18
     * strict:      Strict mode logs few errors to file, giving server error
19
     *              500 for bad usage. Stripped from comments and spaces.
20
     *              Option &verbose and &status disabled.
21
     *
22
     * Default values:
23
     *  mode: 'production'
24
     */
25
     //'mode' => 'production',
26
     'mode' => 'development',
27
     //'mode' => 'strict',
28
29
30
31
    /**
32
     * Where to find the autoloader.
33
     *
34
     * Default values:
35
     *  autoloader:  null
36
     */
37
    'autoloader'   =>  __DIR__ . '/../autoload.php',
38
39
40
41
    /**
42
     * Paths, where are the images stored and where is the cache.
43
     * End all paths with a slash.
44
     *
45
     * Default values:
46
     *  image_path:     __DIR__ . '/img/'
47
     *  cache_path:     __DIR__ . '/../cache/'
48
     *  alias_path:     null
49
     */
50
    'image_path'        =>  __DIR__ . '/img/',
51
    'cache_path'        =>  __DIR__ . '/../cache/',
52
    //'alias_path'   =>  __DIR__ . '/img/alias/',
53
54
55
56
    /**
57
     * Fast track cache. Save a json representation of the image as a
58
     * fast track to the cached version of the image. This avoids some
59
     * processing and allows for quicker load times of cached images.
60
     *
61
     * Default values:
62
     *  fast_track_allow: false
63
     */
64
    //'fast_track_allow' => true,
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...
65
66
67
68
    /**
69
     * Class names to use, to ease dependency injection.
70
     *
71
     * Default values:
72
     *  CImage: CImage
73
     *  CCache: CCache
74
     *  CFastTrackCache: CFastTrackCache
75
     */
76
     //'CImage' => 'CImage',
77
     //'CCache' => 'CCache',
78
     //'CFastTrackCache' => 'CFastTrackCache',
79
80
81
82
    /**
83
     * Use password to protect from missusage, send &pwd=... or &password=..
84
     * with the request to match the password or set to false to disable.
85
     * Passwords are only used together with options for remote download
86
     * and aliasing.
87
     *
88
     * Create a passwords like this, depending on the type used:
89
     *  text: 'my_password'
90
     *  md5:  md5('my_password')
91
     *  hash: password_hash('my_password', PASSWORD_DEFAULT)
92
     *
93
     * Default values.
94
     *  password_always: false  // do not always require password,
95
     *  password:        false  // as in do not use password
96
     *  password_type:   'text' // use plain password, not encoded,
97
     */
98
    //'password_always' => false, // always require password,
99
    //'password'        => false, // "secret-password",
100
    //'password_type'   => 'text', // supports 'text', 'md5', 'hash',
101
102
103
104
    /**
105
     * Allow or disallow downloading of remote images available on
106
     * remote servers. Default is to disallow remote download.
107
     *
108
     * When enabling remote download, the default is to allow download any
109
     * link starting with http or https. This can be changed using
110
     * remote_pattern.
111
     *
112
     * When enabling remote_whitelist a check is made that the hostname of the
113
     * source to download matches the whitelist. By default the check is
114
     * disabled and thereby allowing download from any hosts.
115
     *
116
     * Default values.
117
     *  remote_allow:     false
118
     *  remote_pattern:   null  // use default values from CImage which is to
119
     *                          // allow download from any http- and
120
     *                          // https-source.
121
     *  remote_whitelist: null  // use default values from CImage which is to
122
     *                          // allow download from any hosts.
123
     */
124
    //'remote_allow'     => true,
125
    //'remote_pattern'   => '#^https?://#',
126
    //'remote_whitelist' => array(
127
    //    '\.facebook\.com$',
128
    //    '^(?:images|photos-[a-z])\.ak\.instagram\.com$',
129
    //    '\.google\.com$'
130
    //),
131
132
133
134
    /**
135
     * Use backup image if src-image is not found on disk. The backup image
136
     * is only available for local images and based on wether the original
137
     * image is found on disk or not. The backup image must be a local image
138
     * or the dummy image.
139
     *
140
     * Default value:
141
     *  src_alt:  null //disabled by default
142
     */
143
     //'src_alt' => 'car.png',
144
     //'src_alt' => 'dummy',
145
146
147
148
    /**
149
     * A regexp for validating characters in the image or alias filename.
150
     *
151
     * Default value:
152
     *  valid_filename:  '#^[a-z0-9A-Z-/_ \.:]+$#'
153
     *  valid_aliasname: '#^[a-z0-9A-Z-_]+$#'
154
     */
155
     //'valid_filename'  => '#^[a-z0-9A-Z-/_ \.:]+$#',
156
     //'valid_aliasname' => '#^[a-z0-9A-Z-_]+$#',
157
158
159
160
     /**
161
      * Change the default values for CImage quality and compression used
162
      * when saving images.
163
      *
164
      * Default value:
165
      *  jpg_quality:     null, integer between 0-100
166
      *  png_compression: null, integer between 0-9
167
      */
168
      //'jpg_quality'  => 75,
169
      //'png_compression' => 1,
170
171
172
173
      /**
174
       * Convert the image to srgb before processing. Saves the converted
175
       * image in a cache subdir 'srgb'. This option is default false but can
176
       * be changed to default true to do this conversion for all images.
177
       * This option requires PHP extension imagick and will silently fail
178
       * if that is not installed.
179
       *
180
       * Default value:
181
       *  srgb_default:      false
182
       *  srgb_colorprofile: __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc'
183
       */
184
       //'srgb_default' => false,
185
       //'srgb_colorprofile' => __DIR__ . '/../icc/sRGB_IEC61966-2-1_black_scaled.icc',
186
187
188
189
       /**
190
        * Set skip-original to true to always process the image and use
191
        * the cached version. Default is false and to use the original
192
        * image when its no processing needed.
193
        *
194
        * Default value:
195
        *  skip_original: false
196
        */
197
        //'skip_original' => true,
198
199
200
201
      /**
202
       * A function (hook) can be called after img.php has processed all
203
       * configuration options and before processing the image using CImage.
204
       * The function receives the $img variabel and an array with the
205
       * majority of current settings.
206
       *
207
       * Default value:
208
       *  hook_before_CImage:     null
209
       */
210
       /*'hook_before_CImage' => function (CImage $img, Array $allConfig) {
211
           if ($allConfig['newWidth'] > 10) {
212
               $allConfig['newWidth'] *= 2;
213
           }
214
           return $allConfig;
215
       },*/
216
217
218
219
       /**
220
        * Add header for cache control when outputting images.
221
        *
222
        * Default value:
223
        *  cache_control: null, or set to string
224
        */
225
        //'cache_control' => "max-age=86400",
226
227
228
229
     /**
230
      * The name representing a dummy image which is automatically created
231
      * and stored as a image in the dir CACHE_PATH/dummy. The dummy image
232
      * can then be used as a placeholder image.
233
      * The dir CACHE_PATH/dummy is automatically created when needed.
234
      * Write protect the CACHE_PATH/dummy to prevent creation of new
235
      * dummy images, but continue to use the existing ones.
236
      *
237
      * Default value:
238
      *  dummy_enabled:  true as default, disable dummy feature by setting
239
      *                  to false.
240
      *  dummy_filename: 'dummy' use this as ?src=dummy to create a dummy image.
241
      */
242
      //'dummy_enabled' => true,
243
      //'dummy_filename' => 'dummy',
244
245
246
247
     /**
248
     * Check that the imagefile is a file below 'image_path' using realpath().
249
     * Security constraint to avoid reaching images outside image_path.
250
     * This means that symbolic links to images outside the image_path will
251
     * fail.
252
     *
253
     * Default value:
254
     *  image_path_constraint: true
255
     */
256
     //'image_path_constraint' => false,
257
258
259
260
     /**
261
     * Set default timezone.
262
     *
263
     * Default values.
264
     *  default_timezone: ini_get('default_timezone') or 'UTC'
265
     */
266
    //'default_timezone' => 'UTC',
267
268
269
270
    /**
271
     * Max image dimensions, larger dimensions results in 404.
272
     * This is basically a security constraint to avoid using resources on creating
273
     * large (unwanted) images.
274
     *
275
     * Default values.
276
     *  max_width:  2000
277
     *  max_height: 2000
278
     */
279
    //'max_width'     => 2000,
280
    //'max_height'    => 2000,
281
282
283
284
    /**
285
     * Set default background color for all images. Override it using
286
     * option bgColor.
287
     * Colorvalue is 6 digit hex string between 000000-FFFFFF
288
     * or 8 digit hex string if using the alpha channel where
289
     * the alpha value is between 00 (opaqe) and 7F (transparent),
290
     * that is between 00000000-FFFFFF7F.
291
     *
292
     * Default values.
293
     *  background_color: As specified by CImage
294
     */
295
    //'background_color' => "FFFFFF",
296
    //'background_color' => "FFFFFF7F",
297
298
299
300
    /**
301
     * Post processing of images using external tools, set to true or false
302
     * and set command to be executed.
303
     *
304
     * Default values.
305
     *
306
     *  png_filter:        false
307
     *  png_filter_cmd:    '/usr/local/bin/optipng -q'
308
     *
309
     *  png_deflate:       false
310
     *  png_deflate_cmd:   '/usr/local/bin/pngout -q'
311
     *
312
     *  jpeg_optimize:     false
313
     *  jpeg_optimize_cmd: '/usr/local/bin/jpegtran -copy none -optimize'
314
     */
315
    /*
0 ignored issues
show
Unused Code Comprehensibility introduced by
49% 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...
316
    'postprocessing' => array(
317
        'png_filter'        => false,
318
        'png_filter_cmd'    => '/usr/local/bin/optipng -q',
319
320
        'png_deflate'       => false,
321
        'png_deflate_cmd'   => '/usr/local/bin/pngout -q',
322
323
        'jpeg_optimize'     => false,
324
        'jpeg_optimize_cmd' => '/usr/local/bin/jpegtran -copy none -optimize',
325
    ),
326
    */
327
328
329
330
    /**
331
     * Create custom convolution expressions, matrix 3x3, divisor and
332
     * offset.
333
     *
334
     * Default values.
335
     *  convolution_constant: array()
336
     */
337
    /*
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...
338
    'convolution_constant' => array(
339
        //'sharpen'       => '-1,-1,-1, -1,16,-1, -1,-1,-1, 8, 0',
340
        //'sharpen-alt'   => '0,-1,0, -1,5,-1, 0,-1,0, 1, 0',
341
    ),
342
    */
343
344
345
346
    /**
347
     * Prevent leeching of images by controlling the hostname of those who
348
     * can access the images. Default is to allow hotlinking.
349
     *
350
     * Password apply when hotlinking is disallowed, use password to allow
351
     * hotlinking.
352
     *
353
     * The whitelist is an array of regexpes for allowed hostnames that can
354
     * hotlink images.
355
     *
356
     * Default values.
357
     *  allow_hotlinking:     true
358
     *  hotlinking_whitelist: array()
359
     */
360
     /*
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...
361
    'allow_hotlinking' => false,
362
    'hotlinking_whitelist' => array(
363
        '^dbwebb\.se$',
364
    ),
365
    */
366
367
368
    /**
369
     * Create custom shortcuts for more advanced expressions.
370
     *
371
     * Default values.
372
     *  shortcut: array(
373
     *      'sepia' => "&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen",
374
     *  )
375
     */
376
     /*
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...
377
    'shortcut' => array(
378
        'sepia' => "&f=grayscale&f0=brightness,-10&f1=contrast,-20&f2=colorize,120,60,0,0&sharpen",
379
    ),*/
380
381
382
383
    /**
384
     * Predefined size constants.
385
     *
386
     * These can be used together with &width or &height to create a constant value
387
     * for a width or height where can be changed in one place.
388
     * Useful when your site changes its layout or if you have a grid to fit images into.
389
     *
390
     * Example:
391
     *  &width=w1  // results in width=613
392
     *  &width=c2  // results in spanning two columns with a gutter, 30*2+10=70
393
     *  &width=c24 // results in spanning whole grid 24*30+((24-1)*10)=950
394
     *
395
     * Default values.
396
     *  size_constant: As specified by the function below.
397
     */
398
    /*
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...
399
    'size_constant' => function () {
400
401
        // Set sizes to map constant to value, easier to use with width or height
402
        $sizes = array(
403
          'w1' => 613,
404
          'w2' => 630,
405
        );
406
407
        // Add grid column width, useful for use as predefined size for width (or height).
408
        $gridColumnWidth = 30;
409
        $gridGutterWidth = 10;
410
        $gridColumns     = 24;
411
412
        for ($i = 1; $i <= $gridColumns; $i++) {
413
            $sizes['c' . $i] = ($gridColumnWidth + $gridGutterWidth) * $i - $gridGutterWidth;
414
        }
415
416
        return $sizes;
417
    },*/
418
419
420
421
    /**
422
     * Predefined aspect ratios.
423
     *
424
     * Default values.
425
     *  aspect_ratio_constant: As the function below.
426
     */
427
    /*'aspect_ratio_constant' => function () {
428
        return array(
429
            '3:1'   => 3/1,
430
            '3:2'   => 3/2,
431
            '4:3'   => 4/3,
432
            '8:5'   => 8/5,
433
            '16:10' => 16/10,
434
            '16:9'  => 16/9,
435
            'golden' => 1.618,
436
        );
437
    },*/
438
439
440
441
    /**
442
     * Default options for ascii image.
443
     *
444
     * Default values as specified below in the array.
445
     *  ascii-options:
446
     *   characterSet:       Choose any character set available in CAsciiArt.
447
     *   scale:              How many pixels should each character
448
     *                       translate to.
449
     *   luminanceStrategy:  Choose any strategy available in CAsciiArt.
450
     *   customCharacterSet: Define your own character set.
451
     */
452
    /*'ascii-options' => array(
453
            "characterSet" => 'two',
454
            "scale" => 14,
455
            "luminanceStrategy" => 3,
456
            "customCharacterSet" => null,
457
        );
458
    },*/
459
);
460