Changeset 29124
- Timestamp:
- Jul 30, 2014, 3:48:35 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions_upload.inc.php
r28714 r29124 220 220 221 221 list($width, $height, $type) = getimagesize($source_filepath); 222 222 223 if (IMAGETYPE_PNG == $type) 223 224 { … … 233 234 $file_path.= 'tif'; 234 235 } 236 elseif (IMAGETYPE_JPEG == $type) 237 { 238 $file_path.= 'jpg'; 239 } 240 elseif (isset($conf['upload_form_all_types']) and $conf['upload_form_all_types']) 241 { 242 $original_extension = strtolower(get_extension($original_filename)); 243 244 if (in_array($original_extension, $conf['file_ext'])) 245 { 246 $file_path.= $original_extension; 247 } 248 else 249 { 250 die('unexpected file type'); 251 } 252 } 235 253 else 236 254 { 237 $file_path.= 'jpg';255 die('forbidden file type'); 238 256 } 239 257 … … 295 313 } 296 314 315 // 316 // generate pwg_representative in case of video 317 // 318 $ffmpeg_video_exts = array( // extensions tested with FFmpeg 319 'wmv','mov','mkv','mp4','mpg','flv','asf','xvid','divx','mpeg', 320 'avi','rm', 321 ); 322 323 if (isset($original_extension) and in_array($original_extension, $ffmpeg_video_exts)) 324 { 325 $representative_file_path = dirname($file_path).'/pwg_representative/'; 326 $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.'; 327 328 $representative_ext = 'jpg'; 329 $representative_file_path.= $representative_ext; 330 331 prepare_directory(dirname($representative_file_path)); 332 333 $second = 1; 334 335 $ffmpeg = $conf['ffmpeg_dir'].'ffmpeg'; 336 $ffmpeg.= ' -i "'.$file_path.'"'; 337 $ffmpeg.= ' -an -ss '.$second; 338 $ffmpeg.= ' -t 1 -r 1 -y -vcodec mjpeg -f mjpeg'; 339 $ffmpeg.= ' "'.$representative_file_path.'"'; 340 341 // file_put_contents('/tmp/ffmpeg.log', "\n==== ".date('c')."\n".__FUNCTION__.' : '.$ffmpeg."\n", FILE_APPEND); 342 343 @exec($ffmpeg); 344 345 if (!file_exists($representative_file_path)) 346 { 347 $representative_ext = null; 348 } 349 } 350 351 if (isset($original_extension) and 'pdf' == $original_extension and pwg_image::get_library() == 'ext_imagick') 352 { 353 $representative_file_path = dirname($file_path).'/pwg_representative/'; 354 $representative_file_path.= get_filename_wo_extension(basename($file_path)).'.'; 355 356 $representative_ext = 'jpg'; 357 $representative_file_path.= $representative_ext; 358 359 prepare_directory(dirname($representative_file_path)); 360 361 $exec = $conf['ext_imagick_dir'].'convert'; 362 $exec.= ' -quality 98'; 363 $exec.= ' "'.realpath($file_path).'"[0]'; 364 365 $dest = pathinfo($representative_file_path); 366 $exec.= ' "'.realpath($dest['dirname']).'/'.$dest['basename'].'"'; 367 $exec.= ' 2>&1'; 368 @exec($exec, $returnarray); 369 } 370 297 371 if (pwg_image::get_library() != 'gd') 298 372 { … … 477 551 function is_valid_image_extension($extension) 478 552 { 479 return in_array(strtolower($extension), array('jpg', 'jpeg', 'png', 'gif')); 553 global $conf; 554 555 if (isset($conf['upload_form_all_types']) and $conf['upload_form_all_types']) 556 { 557 $extensions = $conf['file_ext']; 558 } 559 else 560 { 561 $extensions = $conf['picture_ext']; 562 } 563 564 return array_unique(array_map('strtolower', $extensions)); 480 565 } 481 566 -
trunk/admin/include/photos_add_direct_prepare.inc.php
r28919 r29124 94 94 ); 95 95 96 $upload_file_types = 'jpeg, png, gif'; 97 98 if (pwg_image::get_library() == 'ext_imagick') 99 { 100 $upload_file_types.= ', tiff'; 101 $template->assign('tif_enabled', true); 102 } 103 104 if (false) // TODO manage zip files in pwg.images.upload 105 { 106 $upload_file_types.= ', zip'; 107 } 96 $unique_exts = array_unique( 97 array_map( 98 'strtolower', 99 $conf['upload_form_all_types'] ? $conf['file_ext'] : $conf['picture_ext'] 100 ) 101 ); 102 108 103 $template->assign( 109 104 array( 110 'upload_file_types' => $upload_file_types, 105 'upload_file_types' => implode(', ', $unique_exts), 106 'file_exts' => implode(',', $unique_exts), 111 107 ) 112 108 ); -
trunk/admin/themes/default/template/photos_add_direct.tpl
r29009 r29124 81 81 // Specify what files to browse for 82 82 mime_types: [ 83 {title : "Image files", extensions : "jpeg,jpg,gif,png"}, 84 {title : "Zip files", extensions : "zip"} 83 {title : "Image files", extensions : "{/literal}{$file_exts}{literal}"} 85 84 ] 86 85 }, -
trunk/include/config_default.inc.php
r28558 r29124 54 54 // $conf['order_by_inside_category_custom'] = $conf['order_by_custom']; 55 55 56 // file_ext : file extensions (case sensitive) authorized57 $conf['file_ext'] = array('jpg','JPG','jpeg','JPEG',58 'png','PNG','gif','GIF','mpg','zip',59 'avi','mp3','ogg');60 61 56 // picture_ext : file extensions for picture file, must be a subset of 62 57 // file_ext 63 $conf['picture_ext'] = array('jpg','JPG','jpeg','JPEG', 64 'png','PNG','gif','GIF'); 58 $conf['picture_ext'] = array('jpg','JPG','jpeg','JPEG','png','PNG','gif','GIF'); 59 60 // file_ext : file extensions (case sensitive) authorized 61 $conf['file_ext'] = array_merge( 62 $conf['picture_ext'], 63 array('tiff', 'tif', 'mpg','zip','avi','mp3','ogg') 64 ); 65 65 66 66 // top_number : number of element to display for "best rated" and "most … … 799 799 // JPEG or PNG file format 800 800 $conf['tiff_representative_ext'] = 'png'; 801 802 // in the upload form, let users upload only picture_exts or all file_exts? 803 // for some file types, Piwigo will try to generate a pwg_representative 804 // (TIFF, videos, PDF) 805 $conf['upload_form_all_types'] = false; 806 807 // If we try to generate a pwg_representative for a video we use ffmpeg. If 808 // "ffmpeg" is not visible by the web user, you can define the full path of 809 // the directory where "ffmpeg" executable is. 810 $conf['ffmpeg_dir'] = ''; 801 811 ?> -
trunk/include/ws_functions/pwg.images.php
r28554 r29124 1360 1360 id, 1361 1361 name, 1362 representative_ext, 1362 1363 path 1363 1364 FROM '.IMAGES_TABLE.'
Note: See TracChangeset
for help on using the changeset viewer.