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 *
RevLine 
[2]1<?php
[1040]2
[2055]3        require_once '../../header.session.inc.php';
4
[2]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'];
[27]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        }
[2]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'];
[178]22        $msg_folder = mb_convert_encoding($msg_folder,"UTF7-IMAP", mb_detect_encoding($msg_folder, "UTF-8, ISO-8859-1", true));
[27]23        $mb = imap_open("{".$imap_server.":".$imap_port.$imap_options."}".$msg_folder, $username, $password);
[178]24
[2]25        $image_mail = imap_fetchbody($mb, $msg_num, $msg_part, FT_UID);
26        $image = imap_base64($image_mail);
[2627]27        $pic = @imagecreatefromstring ($image);
[2]28       
[2627]29        if($pic !== FALSE) {
30                header("Content-Type: ".$file_type);
31                header("Content-Disposition: inline");         
[2]32        $width = imagesx($pic);
33        $height = imagesy($pic);
34        $twidth = 160; # width of the thumb 160 pixel
35        $theight = $twidth * $height / $width; # calculate height
[2783]36        $theight =  $theight < 1 ? 1 : $theight;
[2]37        $thumb = imagecreatetruecolor ($twidth, $theight);
38                imagecopyresized($thumb, $pic, 0, 0, 0, 0,$twidth, $theight, $width, $height); # resize image into thumb
[2627]39                imagejpeg($thumb,"",75); # Thumbnail as JPEG           
40        }
[1037]41?>
Note: See TracBrowser for help on using the repository browser.