[Linpha-cvs] SF.net SVN: linpha: [4749] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <bz...@us...> - 2007-07-12 12:34:19
|
Revision: 4749 http://svn.sourceforge.net/linpha/?rev=4749&view=rev Author: bzrudi Date: 2007-07-12 05:34:14 -0700 (Thu, 12 Jul 2007) Log Message: ----------- rerwite linGetImageSize() to make videos and other filetypes work again like PDF BMP... Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.identify.class.php trunk/linpha2/lib/classes/linpha.image.class.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-07-11 18:20:15 UTC (rev 4748) +++ trunk/linpha2/ChangeLog 2007-07-12 12:34:14 UTC (rev 4749) @@ -1,3 +1,7 @@ +2007-07-12 bzrudi + * Rewrite linGetImageSize() to make videos and other filetypes like pdf + work again and another bunch of cleanups and fixes + 2007-07-11 bzrudi * Moved /lib/classes/pjmt/ -> /lib/pjmt/ as it's not a class lib at all * Moved /lib/classes/exiftool/ -> /lib/exiftool/ @@ -10,7 +14,6 @@ 2007-07-10 bzrudi * Make use exiftool for video information, so we can remove getid3 completely. I don't like to keep it just to get width and height. - * TODO: save width and height during video import, it's currently missing! * Removed getid3 from svn 2007-07-06 bzrudi Modified: trunk/linpha2/lib/classes/linpha.identify.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.identify.class.php 2007-07-11 18:20:15 UTC (rev 4748) +++ trunk/linpha2/lib/classes/linpha.identify.class.php 2007-07-12 12:34:14 UTC (rev 4749) @@ -114,10 +114,6 @@ * This function extends PHP's getimagesize() function. This include's * support for TIFF like files with PHP < 4.2.0 and others * - * @todo bzrudi: is this still necesarry using php > 5.x ??? - * @todo flo: yes i think so, imagemagick supports much more images than the gdlib - * but i don't now about the detectTiffType() stuff - * * @author bzrudi,flo * @param string $path path to image * @return array array(width,height,type,img_string) @@ -128,51 +124,75 @@ $ext = LinFilesys::getFileExtFromPath($path); - /** - * $g[2] doesn't exists: -> image type is for example TIFF, but it also can be AVI etc. - * -> use identify from imagemagick to determine the imagetype - * - * but first, check if it is a video, because imagemagick's identify really sucks in detecting videos - * (segmentation faults and wait times about 2 minutes for each file!) - * test results: - * version 5.4.4, 5.5.6, 5.5.7 slow (for one AVI file 2 minutes) - * 6.0.0 works fine - * 6.0.7 segmentation fault - */ - if( !$g[2] ) + //linLog(LOG_TYPE_IMPORT,LOG_INFO,'image',"Got Image Type: ".$g['2']); + if( !$g['2'] ) { $org_type = LinIdentify::convertImagetype($ext); - if(LinIdentify::isVideo($org_type)) + $identify_path = $GLOBALS['linpha']->sql->config->value['sys_im_imagemagick_path'] ."identify"; + + //linLog(LOG_TYPE_IMPORT,LOG_INFO,'image',"No Image Type, asking LinIdentify - GOT: ".$org_type); + + if(!isset($org_type)) { - $g[2] = $org_type; + $g['2'] = "9999999"; } - else + else { - $identify_path = $GLOBALS['linpha']->sql->config->value['sys_im_imagemagick_path'] ."identify"; + $g['2'] = $org_type; + } + + if($org_type == '160') //pdf needs identify to get width and height + { + //linLog(LOG_TYPE_IMPORT,LOG_INFO,'image',"Got PDF ".$g['2']); if( $GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick'] ) { /** * $array_output[0] contains something like '2272 1704 JPEG' */ - LinFilesys::linExec ( $identify_path.' -format "%w %h %m" '.linEscapeString($path), $array_output = Array(), $return_value = 0); + $array_output = Array(); + $return_value = 0; + LinFilesys::linExec ( $identify_path.' -format "%w %h %m" '.linEscapeString($path), $array_output, $return_value); - if($return_value == 0) // identify succeed + if(isset($array_output['0'])) { - if(isset($array_output[0])) - { - print_r($array_output); - exit(); - - $g = explode( " ", $array_output[0] ); - - $g[2] = LinIdentify::convertImagetype($g[2],$path); - } + $file_info = explode( " ", $array_output['0'] ); + $g['0'] = $file_info['0']; + $g['1'] = $file_info['1']; } } } + + /** + * If ImageMagick is avail and type is set to 9999999, try to get infos + * using identify as a last resort + */ + if( $GLOBALS['linpha']->sql->config->value['sys_im_use_imagemagick'] + && $g['2'] == '9999999' ) + { + /** + * $array_output[0] contains something like '2272 1704 JPEG' + */ + $array_output = Array(); + $return_value = 0; + LinFilesys::linExec ( $identify_path.' -format "%w %h %m" '.linEscapeString($path), $array_output, $return_value); + + if(isset($array_output['0'])) + { + $img_info = explode( " ", $array_output['0'] ); + $g['0'] = $img_info['0']; + $g['1'] = $img_info['1']; + $g['2'] = strtolower($img_info['2']); + + } + + } } - else // getimagesize detects mpg and mp4 as type 15, but type 15 is wbmp (look at the mimetype returned by getimagesize), pay attention... + else { + /** + * getimagesize detects mpg and mp4 as type 15, but type 15 is wbmp + * (look at the mimetype returned by getimagesize), pay attention... + */ if($g[2] == 15) { if(LinIdentify::convertImagetype($ext) == 1000) // 1000 = mpg, mpeg, mpe, ... @@ -188,18 +208,24 @@ /** * still don't have an imagetype, take imagetype by fileextension - * @todo what should we do now, getimagesize and identify doesn't handle this files as images and we doesn't know the image height and width, i think they therefore can't convert/handle this file, so we should declare it as unsupported. But we need still a check if it is a video or something other, so we can't remove get_imagetype_from_filename(). That means we should check if get_imagetype_from_filename() returned a value lesser than 1000 and if so, delete it! what do others mean?! flo + * @todo what should we do now, getimagesize and identify doesn't handle + * this files as images and we doesn't know the image height and width, + * i think they therefore can't convert/handle this file, so we should + * declare it as unsupported. But we need still a check if it is a video + * or something other, so we can't remove get_imagetype_from_filename(). + * That means we should check if get_imagetype_from_filename() returned + * a value lesser than 1000 and if so, delete it! what do others mean?! flo */ - if( !$g[2] ) + if( !$g['2'] ) { $type = LinIdentify::getImagetypeFromFilename($path); if($type < 1000) { - $g[2] = LinIdentify::convertImagetype('unsupported'); + $g['2'] = LinIdentify::convertImagetype('unsupported'); } else { - $g[2] = $type; + $g['2'] = $type; } } @@ -208,17 +234,17 @@ * set to not empty to prevent erros on commands like * list($org_width,$org_height,$org_type) = linpha_getimagesize($img2rotate); */ - if(!isset($g[0])) + if(!isset($g['0'])) { - $g[0] = 0; + $g['0'] = '0'; } - if(!isset($g[1])) + if(!isset($g['1'])) { - $g[1] = 0; + $g['1'] = '0'; } - $g[3] = 'width="'.$g[0].'" height="'.$g[1].'"'; + $g['3'] = 'width="'.$g['0'].'" height="'.$g['1'].'"'; return $g; } @@ -404,7 +430,7 @@ 'pcl w' => 157, 'pcx' => 158, 'pdb' => 159, -// 'pdf' => 160, this type shouldn't be handled as image + 'pdf' => 160, 'pfa' => 161, 'pfb' => 162, 'pgm' => 163, Modified: trunk/linpha2/lib/classes/linpha.image.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.image.class.php 2007-07-11 18:20:15 UTC (rev 4748) +++ trunk/linpha2/lib/classes/linpha.image.class.php 2007-07-12 12:34:14 UTC (rev 4749) @@ -469,12 +469,12 @@ function createThumbnailVideo() { - $dummy_thumbnail = LINPHA_DIR.'/lib/graphics/avi_mov.gif'; + $dummy_thumbnail = LINPHA_DIR.'/lib/graphics/video.jpg'; $this->img_thumbsize = $GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_max']; $this->img_quality = 75; - $this->imageTool->orgWidth = 320; - $this->imageTool->orgHeight = 240; - $found_thumbnail = false; + //$this->imageTool->orgWidth = 320; + //$this->imageTool->orgHeight = 240; + $video_thumbnail_created = false; /** * check if there exists a .thm file @@ -496,10 +496,10 @@ $this->imageTool->img_thumbsize = $this->img_thumbsize; $this->imageTool->imgQuality = 75; $this->imageTool->createThumbnail($this->src_file,$this->output_file,$this->rotate); - $found_thumbnail = true; + $video_thumbnail_created = true; } - if(!$found_thumbnail) + if(!$video_thumbnail_created) { /** * try getting thumbnail with exiftool if requested @@ -521,7 +521,7 @@ $this->imageTool->orgWidth = $this->org_width; $this->imageTool->orgHeight = $this->org_height; */ - $found_thumbnail = true; + $video_thumbnail_created = true; } else // try getting at least codec for imagemagick { @@ -546,31 +546,36 @@ if($return_value == 0 && file_exists($this->output_file)) /* && empty($array_output[0]) */ { - $found_thumbnail = true; + $video_thumbnail_created = true; } else { - $found_thumbnail = false; + $video_thumbnail_created = false; } } } else { - $found_thumbnail = false; + $video_thumbnail_created = false; } } } else { - $found_thumbnail = false; + $video_thumbnail_created = false; } } /** * copy the video icon in the lower right corner */ - if($found_thumbnail) + if($video_thumbnail_created) { + /** + * watermark currently broken - image scaling wrong and distorted + * also - so disable temporary (flo?) + */ + /* include_once(LINPHA_DIR.'/lib/plugins/watermark/func.watermark.php'); $this->imageTool->wm_config = Array( 'wm_watermark' => 2, @@ -581,18 +586,20 @@ 'wm_horizontal' => 5, 'wm_vertical' => 5 ); - + */ /** * warning: session will be closed! */ - $this->imageTool->orgWidth = $this->img_thumbsize; // only used with gdlib - $this->imageTool->orgHeight = $this->img_thumbsize; // only used with gdlib + //$this->imageTool->orgWidth = $this->img_thumbsize; // only used with gdlib + //$this->imageTool->orgHeight = $this->img_thumbsize; // only used with gdlib - //$this->imageTool->createImage($this->output_file,$this->output_file,$this->imageTool->orgWidth,$this->imageTool->orgHeight,$this->rotate,$watermark=1); - $this->imageTool->createImage($this->output_file,$this->output_file,$this->img_thumbsize,$this->img_thumbsize,$this->rotate,$watermark=1); + //$this->imageTool->createImage($this->output_file,$this->output_file,$this->img_thumbsize,$this->img_thumbsize,$this->rotate,$watermark=1); } else { + /** + * use default video icon + */ $this->output_file = $dummy_thumbnail; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |