Changeset 9952


Ignore:
Timestamp:
03/31/11 16:26:16 (9 years ago)
Author:
patdenice
Message:

feature:2239
Support GIF format in the upload form (only in GD)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_upload.inc.php

    r9844 r9952  
    239239    { 
    240240      $file_path.= 'png'; 
     241    } 
     242    elseif (IMAGETYPE_GIF == $type) 
     243    { 
     244      $file_path.= 'gif'; 
    241245    } 
    242246    else 
     
    479483  $ratio_width  = $width / $max_width; 
    480484  $ratio_height = $height / $max_height; 
     485  $destination_width = $width;  
     486  $destination_height = $height; 
    481487   
    482488  // maximal size exceeded ? 
     
    514520  } 
    515521 
    516   if (is_imagick()) 
     522  $extension = strtolower(get_extension($source_filepath)); 
     523 
     524  if (is_imagick() and $extension != 'gif') 
    517525  { 
    518526    return pwg_image_resize_im($source_filepath, $destination_filepath, $max_width, $max_height, $quality, $strip_metadata); 
     
    530538    return false; 
    531539  } 
     540 
     541  $gd_info = gd_info(); 
    532542 
    533543  // extension of the picture filename 
     
    543553    $source_image = imagecreatefrompng($source_filepath); 
    544554  } 
     555  elseif ($extension == 'gif' and $gd_info['GIF Read Support'] and $gd_info['GIF Create Support']) 
     556  { 
     557    $source_image = imagecreatefromgif($source_filepath); 
     558  } 
    545559  else 
    546560  { 
    547     die('unsupported file extension'); 
     561    die('[GD] unsupported file extension'); 
    548562  } 
    549563 
     
    595609    imagepng($destination_image, $destination_filepath); 
    596610  } 
     611  elseif ($extension == 'gif') 
     612  { 
     613    imagegif($destination_image, $destination_filepath); 
     614  } 
    597615  else 
    598616  { 
     
    665683 
    666684  if (!$conf['upload_form_automatic_rotation']) 
     685  { 
     686    return null; 
     687  } 
     688 
     689  list($width, $height, $type) = getimagesize($source_filepath); 
     690  if (IMAGETYPE_JPEG != $type) 
    667691  { 
    668692    return null; 
     
    712736function is_valid_image_extension($extension) 
    713737{ 
    714   return in_array(strtolower($extension), array('jpg', 'jpeg', 'png')); 
     738  return in_array(strtolower($extension), array('jpg', 'jpeg', 'png', 'gif')); 
    715739} 
    716740 
Note: See TracChangeset for help on using the changeset viewer.