File: example.1.inc

package info (click to toggle)
php-imlib 0.7-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,020 kB
  • ctags: 817
  • sloc: php: 2,464; ansic: 1,324; xml: 94; makefile: 67; sh: 12
file content (37 lines) | stat: -rw-r--r-- 1,029 bytes parent folder | download | duplicates (4)
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
<pre>
&lt;?php

// If you compile php_imlib as a self-contained extension, you'll need to
// load it here.

//dl('imlib.so');

if (!isset($file) || $file == 'none')
{
   ?&gt;
   &lt;form method=&quot;post&quot; action=&quot;&lt;?= $PHP_SELF ?&gt;&quot; enctype=&quot;multipart/form-data&quot;&gt;
   Filename&lt;br&gt;&lt;input type=&quot;file&quot; name=&quot;file&quot;&gt;&lt;br&gt;
   &lt;input type=&quot;submit&quot; name=&quot;Scale&quot;&gt;
   &lt;/form&gt;
   &lt;?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);
}

?&gt;
</pre>