source: branches/2.0/expressoMail1_2/inc/show_thumbs.php @ 2783

Revision 2783, 1.6 KB checked in by niltonneto, 14 years ago (diff)

Ticket #1051 - Corrigindo problema no cálculo do $theight para o thumb.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2
3        require_once '../../header.session.inc.php';
4
5        $username = $_SESSION['phpgw_info']['expressomail']['user']['userid'];
6        $password = $_SESSION['phpgw_info']['expressomail']['user']['passwd'];
7        $imap_server = $_SESSION['phpgw_info']['expressomail']['email_server']['imapServer'];
8        $imap_port      = $_SESSION['phpgw_info']['expressomail']['email_server']['imapPort'];
9        if ($_SESSION['phpgw_info']['expressomail']['email_server']['imapTLSEncryption'] == 'yes')
10        {
11                $imap_options = '/tls/novalidate-cert';
12        }
13        else
14        {
15                $imap_options = '/notls/novalidate-cert';
16        }
17
18        $file_type = $_GET['file_type'];
19        $msg_num = $_GET['msg_num'];
20        $msg_part = $_GET['msg_part'];
21        $msg_folder = $_GET['msg_folder'];
22        $msg_folder = mb_convert_encoding($msg_folder,"UTF7-IMAP", mb_detect_encoding($msg_folder, "UTF-8, ISO-8859-1", true));
23        $mb = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password);
24
25        $image_mail = imap_fetchbody($mb, $msg_num, $msg_part, FT_UID);
26        $image = imap_base64($image_mail);
27        $pic = @imagecreatefromstring ($image);
28       
29        if($pic !== FALSE) {
30                header("Content-Type: ".$file_type);
31                header("Content-Disposition: inline");         
32        $width = imagesx($pic);
33        $height = imagesy($pic);
34        $twidth = 160; # width of the thumb 160 pixel
35        $theight = $twidth * $height / $width; # calculate height
36        $theight =  $theight < 1 ? 1 : $theight;
37        $thumb = imagecreatetruecolor ($twidth, $theight);
38                imagecopyresized($thumb, $pic, 0, 0, 0, 0,$twidth, $theight, $width, $height); # resize image into thumb
39                imagejpeg($thumb,"",75); # Thumbnail as JPEG           
40        }
41?>
Note: See TracBrowser for help on using the repository browser.