summaryrefslogtreecommitdiffhomepage
path: root/examples/scale.php
blob: 33be4c90f367966cb6b6dbf16761275e35cae865 (plain)
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
<?php

if (!isset($file) || $file == 'none')
{
   ?>
   <form method="post" action="<?= $PHP_SELF ?>" enctype="multipart/form-data">
   Filename<br><input type="file" name="file"><br>
   <input type="submit" name="Scale">
   </form>
   <?php
}
else
{
   $src = imlib_load_image($file);
   $width = imlib_image_get_width($src);
   $height = imlib_image_get_height($src);
   $ratio = $height / $width;
   $dst = imlib_create_cropped_scaled_image($src, 0,0, $width,$height,
                                            200, 200 * $ratio);

   // Alternatively, you could simply say
   //$dst = imlib_create_scaled_image($src, 200, '');

   Header('Content-type: image/' . imlib_image_format($src));
   imlib_dump_image($dst);
   imlib_free_image($src);
   imlib_free_image($dst);
}

?>