-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·41 lines (32 loc) · 1003 Bytes
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env php
<?php
require 'vendor/autoload.php';
const INPUT_NAME = __DIR__ . '/assets/input.jpg';
const OUTPUT_NAME_1 = __DIR__ . '/assets/output1.jpg';
const OUTPUT_NAME_2 = __DIR__ . '/assets/output2.jpg';
const OUTPUT_NAME_3 = __DIR__ . '/assets/output3.jpg';
use Intervention\Image\ImageManager;
$manager = new ImageManager([
'driver' => 'imagick',
]);
if (file_exists(OUTPUT_NAME_1)) {
unlink(OUTPUT_NAME_1);
}
if (file_exists(OUTPUT_NAME_2)) {
unlink(OUTPUT_NAME_2);
}
if (file_exists(OUTPUT_NAME_3)) {
unlink(OUTPUT_NAME_3);
}
$image = $manager->make(INPUT_NAME);
$image->resize(100, null, function ($constraint) {
$constraint->aspectRatio();
})->save(OUTPUT_NAME_1);
$image = $manager->make(INPUT_NAME);
$image->resize(100, 130, function ($constraint) {
$constraint->aspectRatio();
})->save(OUTPUT_NAME_2);
$image = $manager->make(INPUT_NAME);
$image->resize(100, 131, function ($constraint) {
$constraint->aspectRatio();
})->save(OUTPUT_NAME_3);