当前位置: 首页>>代码示例>>PHP>>正文


PHP get_utility_path函数代码示例

本文整理汇总了PHP中get_utility_path函数的典型用法代码示例。如果您正苦于以下问题:PHP get_utility_path函数的具体用法?PHP get_utility_path怎么用?PHP get_utility_path使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_utility_path函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_utility_version

function get_utility_version($utilityname)
{
    global $lang;
    # Get utility path.
    $utility_fullpath = get_utility_path($utilityname, $path);
    # Get utility display name.
    $name = get_utility_displayname($utilityname);
    # Check path.
    if ($path == null) {
        # There was no complete path to check - the utility is not installed.
        $error_msg = $lang["status-notinstalled"];
        return array("name" => $name, "version" => "", "success" => false, "error" => $error_msg);
    }
    if ($utility_fullpath == false) {
        # There was a path but it was incorrect - the utility couldn't be found.
        $error_msg = $lang["status-fail"] . ":<br>" . str_replace("?", $path, $lang["softwarenotfound"]);
        return array("name" => $name, "version" => "", "success" => false, "error" => $error_msg);
    }
    # Look up the argument to use to get the version.
    switch (strtolower($utilityname)) {
        case "exiftool":
            $version_argument = "-ver";
            break;
        default:
            $version_argument = "-version";
    }
    # Check execution and find out version.
    $version_command = $utility_fullpath . " " . $version_argument;
    $version = run_command($version_command);
    switch (strtolower($utilityname)) {
        case "im-convert":
            if (strpos($version, "ImageMagick") !== false) {
                $name = "ImageMagick";
            }
            if (strpos($version, "GraphicsMagick") !== false) {
                $name = "GraphicsMagick";
            }
            if ($name == "ImageMagick" || $name == "GraphicsMagick") {
                $expected = true;
            } else {
                $expected = false;
            }
            break;
        case "ghostscript":
            if (strpos(strtolower($version), "ghostscript") === false) {
                $expected = false;
            } else {
                $expected = true;
            }
            break;
        case "ffmpeg":
            if (strpos(strtolower($version), "ffmpeg") === false) {
                $expected = false;
            } else {
                $expected = true;
            }
            break;
        case "exiftool":
            if (preg_match("/^([0-9]+)+\\.([0-9]+)\$/", $version) == false) {
                $expected = false;
            } else {
                $expected = true;
            }
            break;
    }
    if ($expected == false) {
        # There was a correct path but the version check failed - unexpected output when executing the command.
        $error_msg = $lang["status-fail"] . ":<br>" . str_replace(array("%command", "%output"), array($version_command, $version), $lang["execution_failed"]);
        return array("name" => $name, "version" => "", "success" => false, "error" => $error_msg);
    } else {
        # There was a working path and the output was the expected - the version is returned.
        $s = explode("\n", $version);
        return array("name" => $name, "version" => $s[0], "success" => true, "error" => "");
    }
}
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:75,代码来源:check.php

示例2: get_original_imagesize

function get_original_imagesize($ref = "", $path = "", $extension = "jpg")
{
    $fileinfo = array();
    if ($ref == "" || $path == "") {
        return false;
    }
    global $imagemagick_path, $imagemagick_calculate_sizes;
    $file = $path;
    $filesize = filesize_unlimited($file);
    # imagemagick_calculate_sizes is normally turned off
    if (isset($imagemagick_path) && $imagemagick_calculate_sizes) {
        # Use ImageMagick to calculate the size
        $prefix = '';
        # Camera RAW images need prefix
        if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)) {
            $prefix = $rawext[0] . ':';
        }
        # Locate imagemagick.
        $identify_fullpath = get_utility_path("im-identify");
        if ($identify_fullpath == false) {
            exit("Could not find ImageMagick 'identify' utility at location '{$imagemagick_path}'.");
        }
        # Get image's dimensions.
        $identcommand = $identify_fullpath . ' -format %wx%h ' . escapeshellarg($prefix . $file) . '[0]';
        $identoutput = run_command($identcommand);
        preg_match('/^([0-9]+)x([0-9]+)$/ims', $identoutput, $smatches);
        @(list(, $sw, $sh) = $smatches);
        if ($sw != '' && $sh != '') {
            sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "', '" . $sw . "', '" . $sh . "', '" . $filesize . "')");
        }
    } else {
        # check if this is a raw file.
        $rawfile = false;
        if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)) {
            $rawfile = true;
        }
        # Use GD to calculate the size
        if (!(@(list($sw, $sh) = @getimagesize($file)) === false) && !$rawfile) {
            sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "', '" . $sw . "', '" . $sh . "', '" . $filesize . "')");
        } else {
            # Assume size cannot be calculated.
            $sw = "?";
            $sh = "?";
            global $ffmpeg_supported_extensions;
            if (in_array(strtolower($extension), $ffmpeg_supported_extensions) && function_exists('json_decode')) {
                $ffprobe_fullpath = get_utility_path("ffprobe");
                $file = get_resource_path($ref, true, "", false, $extension);
                $ffprobe_output = run_command($ffprobe_fullpath . " -v 0 " . escapeshellarg($file) . " -show_streams -of json");
                $ffprobe_array = json_decode($ffprobe_output, true);
                # Different versions of ffprobe store the dimensions in different parts of the json output. Test both.
                if (!empty($ffprobe_array['width'])) {
                    $sw = intval($ffprobe_array['width']);
                }
                if (!empty($ffprobe_array['height'])) {
                    $sh = intval($ffprobe_array['height']);
                }
                if (isset($ffprobe_array['streams']) && is_array($ffprobe_array['streams'])) {
                    foreach ($ffprobe_array['streams'] as $stream) {
                        if (!empty($stream['codec_type']) && $stream['codec_type'] === 'video') {
                            $sw = intval($stream['width']);
                            $sh = intval($stream['height']);
                            break;
                        }
                    }
                }
            }
            if ($sw !== '?' && $sh !== '?') {
                # Size could be calculated after all
                sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "', '" . $sw . "', '" . $sh . "', '" . $filesize . "')");
            } else {
                # Size cannot be calculated.
                $sw = "?";
                $sh = "?";
                # Insert a dummy row to prevent recalculation on every view.
                sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "','0', '0', '" . $filesize . "')");
            }
        }
    }
    $fileinfo[0] = $filesize;
    $fileinfo[1] = $sw;
    $fileinfo[2] = $sh;
    return $fileinfo;
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:83,代码来源:resource_functions.php

示例3: generate_transform_preview

function generate_transform_preview($ref){
	global $storagedir;	
        global $imagemagick_path;
	global $imversion;

	if (!isset($imversion)){
		$imversion = get_imagemagick_version();
	}

	$tmpdir = get_temp_dir();

        // get imagemagick path
        $command = get_utility_path("im-convert");
        if ($command==false) {exit("Could not find ImageMagick 'convert' utility.");}

        $orig_ext = sql_value("select file_extension value from resource where ref = '$ref'",'');
        $originalpath= get_resource_path($ref,true,'',false,$orig_ext);

	# Since this check is in get_temp_dir() omit: if(!is_dir($storagedir."/tmp")){mkdir($storagedir."/tmp",0777);}
	if(!is_dir(get_temp_dir() . "/transform_plugin")){mkdir(get_temp_dir() . "/transform_plugin",0777);}

       if ($imversion[0]<6 || ($imversion[0] == 6 &&  $imversion[1]<7) || ($imversion[0] == 6 && $imversion[1] == 7 && $imversion[2]<5)){
                $colorspace1 = " -colorspace sRGB ";
                $colorspace2 =  " -colorspace RGB ";
        } else {
                $colorspace1 = " -colorspace RGB ";
                $colorspace2 =  " -colorspace sRGB ";
        }

        $command .= " \"$originalpath\" +matte -delete 1--1 -flatten $colorspace1 -geometry 450 $colorspace2 \"$tmpdir/transform_plugin/pre_$ref.jpg\"";
        run_command($command);


	// while we're here, clean up any old files still hanging around
	$dp = opendir(get_temp_dir() . "/transform_plugin");
	while ($file = readdir($dp)) {
		if ($file <> '.' && $file <> '..'){
			if ((filemtime(get_temp_dir() . "/transform_plugin/$file")) < (strtotime('-2 days'))) {
				unlink(get_temp_dir() . "/transform_plugin/$file");
			}
		}
	}
	closedir($dp);

        return true;
  
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:47,代码来源:transform_functions.php

示例4: generate_transform_preview

function generate_transform_preview($ref)
{
    global $storagedir;
    global $imagemagick_path;
    global $imversion;
    if (!isset($imversion)) {
        $imversion = get_imagemagick_version();
    }
    $tmpdir = get_temp_dir();
    // get imagemagick path
    $command = get_utility_path("im-convert");
    if ($command == false) {
        exit("Could not find ImageMagick 'convert' utility.");
    }
    $orig_ext = sql_value("select file_extension value from resource where ref = '{$ref}'", '');
    $transformsourcepath = get_resource_path($ref, true, 'scr', false, 'jpg');
    //use screen size if available to save time
    if (!file_exists($transformsourcepath)) {
        $transformsourcepath = get_resource_path($ref, true, '', false, $orig_ext);
    }
    # Since this check is in get_temp_dir() omit: if(!is_dir($storagedir."/tmp")){mkdir($storagedir."/tmp",0777);}
    if (!is_dir(get_temp_dir() . "/transform_plugin")) {
        mkdir(get_temp_dir() . "/transform_plugin", 0777);
    }
    if ($imversion[0] < 6 || $imversion[0] == 6 && $imversion[1] < 7 || $imversion[0] == 6 && $imversion[1] == 7 && $imversion[2] < 5) {
        $colorspace1 = " -colorspace sRGB ";
        $colorspace2 = " -colorspace RGB ";
    } else {
        $colorspace1 = " -colorspace RGB ";
        $colorspace2 = " -colorspace sRGB ";
    }
    $command .= " \"{$transformsourcepath}\"[0] +matte -flatten {$colorspace1} -geometry 450 {$colorspace2} \"{$tmpdir}/transform_plugin/pre_{$ref}.jpg\"";
    run_command($command);
    // while we're here, clean up any old files still hanging around
    $dp = opendir(get_temp_dir() . "/transform_plugin");
    while ($file = readdir($dp)) {
        if ($file != '.' && $file != '..') {
            if (filemtime(get_temp_dir() . "/transform_plugin/{$file}") < strtotime('-2 days')) {
                unlink(get_temp_dir() . "/transform_plugin/{$file}");
            }
        }
    }
    closedir($dp);
    return true;
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:45,代码来源:transform_functions.php

示例5: convertImage

/**
 * Converts the file of the given resource to the new target file with the specified size. The
 * target file format is determined from the suffix of the target file.
 * The original colorspace of the image is retained. If $width and $height are zero, the image
 * keeps its original size.
 */
function convertImage($resource, $page, $alternative, $target, $width, $height)
{
    $command = get_utility_path("im-convert");
    if (!$command) {
        die("Could not find ImageMagick 'convert' utility.");
    }
    $originalPath = get_resource_path($resource['ref'], true, '', false, $resource['file_extension'], -1, $page, false, '', $alternative);
    $command .= " \"{$originalPath}\"[0] -auto-orient";
    if ($width != 0 && $height != 0) {
        # Apply resize ('>' means: never enlarge)
        $command .= " -resize \"{$width}";
        if ($height > 0) {
            $command .= "x{$height}";
        }
        $command .= '>"';
    }
    $command .= " \"{$target}\"";
    run_command($command);
}
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:25,代码来源:utility.php

示例6: get_original_imagesize

function get_original_imagesize($ref = "", $path = "", $extension = "jpg")
{
    $fileinfo = array();
    if ($ref == "" || $path == "") {
        return false;
    }
    global $imagemagick_path, $imagemagick_calculate_sizes;
    $file = $path;
    $filesize = filesize_unlimited($file);
    # imagemagick_calculate_sizes is normally turned off
    if (isset($imagemagick_path) && $imagemagick_calculate_sizes) {
        # Use ImageMagick to calculate the size
        $prefix = '';
        # Camera RAW images need prefix
        if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)) {
            $prefix = $rawext[0] . ':';
        }
        # Locate imagemagick.
        $identify_fullpath = get_utility_path("im-identify");
        if ($identify_fullpath == false) {
            exit("Could not find ImageMagick 'identify' utility at location '{$imagemagick_path}'.");
        }
        # Get image's dimensions.
        $identcommand = $identify_fullpath . ' -format %wx%h ' . escapeshellarg($prefix . $file) . '[0]';
        $identoutput = run_command($identcommand);
        preg_match('/^([0-9]+)x([0-9]+)$/ims', $identoutput, $smatches);
        @(list(, $sw, $sh) = $smatches);
        if ($sw != '' && $sh != '') {
            sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "', '" . $sw . "', '" . $sh . "', '" . $filesize . "')");
        }
    } else {
        # check if this is a raw file.
        $rawfile = false;
        if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)) {
            $rawfile = true;
        }
        # Use GD to calculate the size
        if (!(@(list($sw, $sh) = @getimagesize($file)) === false) && !$rawfile) {
            sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "', '" . $sw . "', '" . $sh . "', '" . $filesize . "')");
        } else {
            # Size cannot be calculated.
            $sw = "?";
            $sh = "?";
            # Insert a dummy row to prevent recalculation on every view.
            sql_query("insert into resource_dimensions (resource, width, height, file_size) values('" . $ref . "','0', '0', '" . $filesize . "')");
        }
    }
    $fileinfo[0] = $filesize;
    $fileinfo[1] = $sw;
    $fileinfo[2] = $sh;
    return $fileinfo;
}
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:52,代码来源:resource_functions.php

示例7: upload_video


//.........这里部分代码省略.........
			curl_close( $curl );
			get_youtube_access_token(true);
			return array(false,$lang["youtube_publish_renewing_token"],true);
			}		
		}
	else
		{
		curl_close( $curl );
		$upload_result=$lang["error"] . curl_error($curl);
		return array(false,curl_errno($curl),false);			
		}
			
	$header = substr($response, 0, $info['header_size']);
	$retVal = array();
	$fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header));
        foreach( $fields as $field ) 
			{
            if( preg_match('/([^:]+): (.+)/m', $field, $match) ) {
                $match[1] = preg_replace('/(?<=^|[\x09\x20\x2D])./e', 'strtoupper("\0")', strtolower(trim($match[1])));
                if( isset($retVal[$match[1]]) ) 
					{
                    $retVal[$match[1]] = array($retVal[$match[1]], $match[2]);
					} 
				else
					{
                    $retVal[$match[1]] = trim($match[2]);
					}
				}
			}
	if (isset($retVal['Location']))
		{
		$location =  $retVal['Location'];
		}
	else
		{
		$upload_result=$lang["youtube_publish_failedupload_nolocation"];
		curl_close( $curl );
		return array(false,$upload_result,false);
		}
	
			
	
	curl_close( $curl );
	
	# Finally upload the file			
	
	# Get file info for upload
	$resource=get_resource_data($ref);
	$alternative=-1;
	$ext=$resource["file_extension"];
	$path=get_resource_path($ref,true,"",false,$ext,-1,1,false,"",$alternative);
	
	# We assign a default mime-type, in case we can find the one associated to the file extension.
	$mime="application/octet-stream";
			
	# Get mime type via exiftool if possible
	$exiftool_fullpath = get_utility_path("exiftool");
	if ($exiftool_fullpath!=false)
		{	
		$command=$exiftool_fullpath . " -s -s -s -t -mimetype " . escapeshellarg($path);
		$mime=run_command($command);
		}	
		
	# Override or correct for lack of exiftool with config mappings	
	if (isset($mime_type_by_extension[$ext]))
		{
		$mime = $mime_type_by_extension[$ext];
		}
	
	
	$video_file = fopen($path, 'rb');
	
	$curl = curl_init($location);
	
	curl_setopt($curl, CURLOPT_PUT, 1);
	curl_setopt($curl, CURLOPT_BINARYTRANSFER, 1);	 
	curl_setopt($curl, CURLOPT_INFILE, $video_file); // file pointer
	curl_setopt($curl, CURLOPT_INFILESIZE, filesize($path));
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($curl, CURLOPT_HEADER, $mime );
	curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 3600); 
	
	
	$response = curl_exec( $curl );
	$videoxml = new SimpleXmlElement($response, LIBXML_NOCDATA);
	
	$urlAtt = $videoxml->link->attributes();
	$youtube_new_url	= $urlAtt['href'];
	$youtube_urlmatch = '#http://(www\.)youtube\.com/watch\?v=([^ &\n]+)(&.*?(\n|\s))?#i';
	preg_match($youtube_urlmatch, $youtube_new_url, $matches);	
	$youtube_new_url=$matches[0];	
		
	# end of actual file upload
	
	
	fclose($video_file);
    $video_file = null;	
	
	return array(true,$youtube_new_url,false);
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:youtube_functions.php

示例8: HookImage_textDownloadModifydownloadfile

function HookImage_textDownloadModifydownloadfile()
{
    global $ref, $path, $tmpfile, $userref, $usergroup, $ext, $resource_data, $image_text_restypes, $image_text_override_groups, $image_text_filetypes, $size, $page, $use_watermark, $alternative, $image_text_height_proportion, $image_text_max_height, $image_text_min_height, $image_text_font, $image_text_position, $image_text_banner_position;
    # Return if not configured for this resource type or if user has requested no overlay and is permitted this
    if (!in_array($resource_data['resource_type'], $image_text_restypes) || !in_array(strtoupper($ext), $image_text_filetypes) || getval("nooverlay", "") != "" && in_array($usergroup, $image_text_override_groups) || $use_watermark) {
        return false;
    }
    # Get text from field
    global $image_text_field_select, $image_text_default_text;
    $overlaytext = get_data_by_field($ref, $image_text_field_select);
    if ($overlaytext == "") {
        if ($image_text_default_text != "") {
            $overlaytext = $image_text_default_text;
        } else {
            return false;
        }
    }
    # If this is not a temporary file having metadata written see if we already have a suitable size with the correct text
    $image_text_saved_file = get_resource_path($ref, true, $size . "_image_text_" . md5($overlaytext . $image_text_height_proportion . $image_text_max_height . $image_text_min_height . $image_text_font . $image_text_position . $image_text_banner_position) . "_", false, $ext, -1, $page);
    if ($path != $tmpfile && file_exists($image_text_saved_file)) {
        $path = $image_text_saved_file;
        return true;
    }
    # Locate imagemagick.
    $identify_fullpath = get_utility_path("im-identify");
    if ($identify_fullpath == false) {
        exit("Could not find ImageMagick 'identify' utility at location '{$imagemagick_path}'.");
    }
    # Get image's dimensions.
    $identcommand = $identify_fullpath . ' -format %wx%h ' . escapeshellarg($path);
    $identoutput = run_command($identcommand);
    preg_match('/^([0-9]+)x([0-9]+)$/ims', $identoutput, $smatches);
    if (@(list(, $width, $height) = $smatches) === false) {
        return false;
    }
    $olheight = floor($height * $image_text_height_proportion);
    if ($olheight < $image_text_min_height && intval($image_text_min_height) != 0) {
        $olheight = $image_text_min_height;
    }
    if ($olheight > $image_text_max_height && intval($image_text_max_height) != 0) {
        $olheight = $image_text_max_height;
    }
    # Locate imagemagick.
    $convert_fullpath = get_utility_path("im-convert");
    if ($convert_fullpath == false) {
        exit("Could not find ImageMagick 'convert' utility at location '{$imagemagick_path}'");
    }
    $tmpolfile = get_temp_dir() . "/" . $ref . "_image_text_" . $userref . "." . $ext;
    $createolcommand = $convert_fullpath . ' -background "#000" -fill white -gravity "' . $image_text_position . '" -font "' . $image_text_font . '" -size ' . $width . 'x' . $olheight . ' caption:" ' . $overlaytext . '  " ' . escapeshellarg($tmpolfile);
    $result = run_command($createolcommand);
    $newdlfile = get_temp_dir() . "/" . $ref . "_image_text_result_" . $userref . "." . $ext;
    if ($image_text_banner_position == "bottom") {
        $convertcommand = $convert_fullpath . " " . escapeshellarg($path) . ' ' . escapeshellarg($tmpolfile) . ' -append ' . escapeshellarg($newdlfile);
    } else {
        $convertcommand = $convert_fullpath . " " . escapeshellarg($tmpolfile) . ' ' . escapeshellarg($path) . ' -append ' . escapeshellarg($newdlfile);
    }
    $result = run_command($convertcommand);
    $oldpath = $path;
    if ($path != $tmpfile) {
        copy($newdlfile, $image_text_saved_file);
    }
    $path = $newdlfile;
    if (strpos(get_temp_dir(), $oldpath) !== false) {
        unlink($oldpath);
    }
    unlink($tmpolfile);
    return true;
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:68,代码来源:download.php

示例9: foreach

 foreach ($rs as $r) {
     # For each range
     $s = explode(":", $r);
     $from = $s[0];
     $to = $s[1];
     if (getval("method", "") == "alternativefile") {
         $aref = add_alternative_file($ref, $lang["pages"] . " " . $from . " - " . $to, "", "", "pdf");
         $copy_path = get_resource_path($ref, true, "", true, "pdf", -1, 1, false, "", $aref);
     } else {
         # Create a new resource based upon the metadata/type of the current resource.
         $copy = copy_resource($ref);
         # Find out the path to the original file.
         $copy_path = get_resource_path($copy, true, "", true, "pdf");
     }
     # Extract this one page to a new resource.
     $ghostscript_fullpath = get_utility_path("ghostscript");
     $gscommand = $ghostscript_fullpath . " -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=" . escapeshellarg($copy_path) . "  -dFirstPage=" . $from . " -dLastPage=" . $to . " " . escapeshellarg($file);
     $output = run_command($gscommand);
     if (getval("method", "") == "alternativefile") {
         # Preview creation for alternative files (enabled via config)
         global $alternative_file_previews;
         if ($alternative_file_previews) {
             create_previews($ref, false, "pdf", false, false, $aref);
         }
         # Update size.
         sql_query("update resource_alt_files set file_size='" . filesize_unlimited($copy_path) . "' where ref='{$aref}'");
     } else {
         # Update the file extension
         sql_query("update resource set file_extension='pdf' where ref='{$copy}'");
         # Create preview for the page.
         create_previews($copy, false, "pdf");
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:31,代码来源:pdf_split.php

示例10: get_imagemagick_version

    include "../../../include/footer.php";
    exit;
}
$imversion = get_imagemagick_version();
// generate a preview image for the operation if it doesn't already exist
if (!file_exists(get_temp_dir() . "/transform_plugin/pre_{$ref}.jpg")) {
    //echo  "generating preview";
    //exit();
    generate_transform_preview($ref) or die("Error generating transform preview.");
}
# Locate imagemagick.
if (!isset($imagemagick_path)) {
    echo "Error: ImageMagick must be configured for crop functionality. Please contact your system administrator.";
    exit;
}
$command = get_utility_path("im-convert");
if ($command == false) {
    exit("Could not find ImageMagick 'convert' utility.");
}
// retrieve file extensions
$orig_ext = sql_value("select file_extension value from resource where ref = '{$ref}'", '');
$preview_ext = sql_value("select preview_extension value from resource where ref = '{$ref}'", '');
// retrieve image paths for preview image and original file
//$previewpath = get_resource_path($ref,true,$cropper_cropsize,false,$preview_ext);
$previewpath = get_temp_dir() . "/transform_plugin/" . $cropper_cropsize . "_{$ref}.jpg";
//echo $previewpath;
//exit();
$originalpath = get_resource_path($ref, true, '', false, $orig_ext);
// retrieve image sizes for original image and preview used for cropping
$cropsizes = getimagesize($previewpath);
$origsizes = getimagesize($originalpath);
开发者ID:vongalpha,项目名称:resourcespace,代码行数:31,代码来源:crop.php

示例11: array_change_key_case

            if ($prettyfieldnames && array_key_exists('field' . $metadata_field['resource_type_field'], $full_fields_options) || array_key_exists($full_fields_options['field' . $metadata_field['resource_type_field']], $results[$i])) {
                $results[$i][$full_fields_options['field' . $metadata_field['resource_type_field']]] = $metadata_field['value'];
            }
        }
        $results[$i] = array_change_key_case($results[$i], CASE_LOWER);
    }
}
$new_results = array();
$results = array_values($results);
foreach ($results as $index => $value) {
    if (!array_key_exists('current', $value) || !array_key_exists('aspect_ratio', $value)) {
        continue;
    }
    $alt_array = sql_query("SELECT ref,name FROM resource_alt_files WHERE resource = " . $value['ref']);
    #Restructure the Results JSON.
    $im_identify_path = get_utility_path('im-identify');
    $get_height_cmd = $im_identify_path . " -format '%[fx:h]' ";
    $get_width_cmd = $im_identify_path . " -format '%[fx:w]' ";
    $sizes = array();
    #if (!isset($image_classification)) {
    #    $image_classification = $results[$i]['Image_Classification'];
    #}
    foreach ($alt_array as $index => $alt_value) {
        $alt_path = get_resource_path($value['ref'], TRUE, '', FALSE, $value['file_extension'], -1, 1, FALSE, '', $alt_value['ref']);
        $alt_path = readlink($alt_path);
        $alt_height_cmd = $get_height_cmd . $alt_path;
        $alt_width_cmd = $get_width_cmd . $alt_path;
        $sizes[$alt_value['name']]['file_path'] = $alt_path;
        $sizes[$alt_value['name']]['size'] = array('height' => trim(shell_exec($alt_height_cmd)), 'width' => trim(shell_exec($alt_width_cmd)));
    }
    $get_height_cmd .= $value['original_filepath'];
开发者ID:vachanda,项目名称:ResourceSpace,代码行数:31,代码来源:index.php

示例12: HookImagestreamUpload_pluploadInitialuploadprocessing

function HookImagestreamUpload_pluploadInitialuploadprocessing()
{
    #Support for uploading multi files as zip
    global $config_windows, $id, $targetDir, $resource_type, $imagestream_restypes, $imagestream_transitiontime, $zipcommand, $use_zip_extension, $userref, $session_hash, $filename, $filename_field, $collection_add, $archiver, $zipcommand, $ffmpeg_fullpath, $ffmpeg_preview_extension, $ffmpeg_preview_options, $ffmpeg_preview_min_height, $ffmpeg_preview_max_height, $ffmpeg_preview_min_width, $ffmpeg_preview_max_width, $lang, $collection_download_settings, $archiver_listfile_argument;
    $ffmpeg_fullpath = get_utility_path("ffmpeg");
    debug("DEBUG: Imagestream - checking restype: " . $resource_type . $imagestream_restypes);
    if (in_array($resource_type, $imagestream_restypes)) {
        debug("DEBUG: Imagestream - uploading file");
        #Check that we have an archiver configured
        $archiver_fullpath = get_utility_path("archiver");
        if (!isset($zipcommand) && !$use_zip_extension) {
            if ($archiver_fullpath == false) {
                exit($lang["archiver-utility-not-found"]);
            }
        }
        echo print_r($_POST) . print_r($_GET);
        if (getval("lastqueued", "")) {
            debug("DEBUG: Imagestream - last queued file");
            $ref = copy_resource(0 - $userref);
            # Copy from user template
            debug("DEBUG: Imagestream - creating resource: " . $ref);
            # Create the zip file
            $imagestreamzippath = get_resource_path($ref, true, "", true, "zip");
            if ($use_zip_extension) {
                $zip = new ZipArchive();
                $zip->open($imagestreamzippath, ZIPARCHIVE::CREATE);
            }
            $deletion_array = array();
            debug("DEBUG: opening directory: " . $targetDir);
            $imagestream_files = opendir($targetDir);
            $imagestream_workingfiles = get_temp_dir() . DIRECTORY_SEPARATOR . "plupload" . DIRECTORY_SEPARATOR . $session_hash . "workingfiles";
            if (!file_exists($imagestream_workingfiles)) {
                if ($config_windows) {
                    @mkdir($imagestream_workingfiles);
                } else {
                    @mkdir($imagestream_workingfiles, 0777, true);
                }
            }
            $filenumber = 00;
            $imagestream_filelist = array();
            while ($imagestream_filelist[] = readdir($imagestream_files)) {
                sort($imagestream_filelist);
            }
            closedir($imagestream_files);
            $imageindex = 1;
            foreach ($imagestream_filelist as $imagestream_file) {
                if ($imagestream_file != '.' && $imagestream_file != '..') {
                    $filenumber = sprintf("%03d", $filenumber);
                    $deletion_array[] = $targetDir . DIRECTORY_SEPARATOR . $imagestream_file;
                    if (!$use_zip_extension) {
                        $imagestreamcmd_file = get_temp_dir(false, $id) . "/imagestreamzipcmd" . $imagestream_file . ".txt";
                        $fh = fopen($imagestreamcmd_file, 'w') or die("can't open file");
                        fwrite($fh, $targetDir . DIRECTORY_SEPARATOR . $imagestream_file . "\r\n");
                        fclose($fh);
                        $deletion_array[] = $imagestreamcmd_file;
                    }
                    if ($use_zip_extension) {
                        debug("DEBUG: Imagestream - adding filename: " . $imagestream_file);
                        debug("DEBUG: using zip PHP extension, set up zip at : " . $imagestreamzippath);
                        $zip->addFile($imagestream_file);
                        debug(" Added files number : " . $zip->numFiles);
                        $wait = $zip->close();
                        debug("DEBUG: closed zip");
                    } else {
                        if ($archiver_fullpath) {
                            debug("DEBUG: using archiver, running command: \r\n" . $archiver_fullpath . " " . $collection_download_settings[0]["arguments"] . " " . escapeshellarg($imagestreamzippath) . " " . $archiver_listfile_argument . escapeshellarg($imagestream_file));
                            run_command($archiver_fullpath . " " . $collection_download_settings[0]["arguments"] . " " . escapeshellarg($imagestreamzippath) . " " . $archiver_listfile_argument . escapeshellarg($imagestreamcmd_file));
                        } else {
                            if (!$use_zip_extension) {
                                if ($config_windows) {
                                    debug("DEBUG: using zip command: . {$zipcommand} " . escapeshellarg($imagestreamzippath) . " @" . escapeshellarg($imagestreamcmd_file));
                                    exec("{$zipcommand} " . escapeshellarg($imagestreamzippath) . " @" . escapeshellarg($imagestreamcmd_file));
                                } else {
                                    # Pipe the command file, containing the filenames, to the executable.
                                    exec("{$zipcommand} " . escapeshellarg($imagestreamzippath) . " -@ < " . escapeshellarg($imagestreamcmd_file));
                                }
                            }
                        }
                    }
                    #Create a JPEG if not already in that format
                    $imagestream_file_parts = explode('.', $imagestream_file);
                    $imagestream_file_ext = $imagestream_file_parts[count($imagestream_file_parts) - 1];
                    $imagestream_file_noext = basename($imagestream_file, $imagestream_file_ext);
                    global $imagemagick_path, $imagemagick_quality;
                    $icc_transform_complete = false;
                    # Camera RAW images need prefix
                    if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $imagestream_file_ext, $rawext)) {
                        $prefix = $rawext[0] . ':';
                    }
                    # Locate imagemagick.
                    $convert_fullpath = get_utility_path("im-convert");
                    if ($convert_fullpath == false) {
                        exit("Could not find ImageMagick 'convert' utility at location '{$imagemagick_path}'.");
                    }
                    $prefix = '';
                    if ($prefix == "cr2:" || $prefix == "nef:") {
                        $flatten = "";
                    } else {
                        $flatten = "-flatten";
                    }
//.........这里部分代码省略.........
开发者ID:chandradrupal,项目名称:resourcespace,代码行数:101,代码来源:upload_plupload.php

示例13: get_imagemagick_version

function get_imagemagick_version($array = true)
{
    // return version number of ImageMagick, or false if it is not installed or cannot be determined.
    // will return an array of major/minor/version/patch if $array is true, otherwise just the version string
    # Locate imagemagick, or return false if it isn't installed
    $convert_fullpath = get_utility_path("im-convert");
    if ($convert_fullpath == false) {
        return false;
    }
    $versionstring = run_command($convert_fullpath . " --version");
    // example:
    //          Version: ImageMagick 6.5.0-0 2011-02-18 Q16 http://www.imagemagick.org
    //          Copyright: Copyright (C) 1999-2009 ImageMagick Studio LLC
    if (preg_match("/^Version: +ImageMagick (\\d+)\\.(\\d+)\\.(\\d+)-(\\d+) /", $versionstring, $matches)) {
        $majorver = $matches[1];
        $minorver = $matches[2];
        $revision = $matches[3];
        $patch = $matches[4];
        if ($array) {
            return array($majorver, $minorver, $revision, $patch);
        } else {
            return "{$majorver}.{$minorver}.{$revision}-{$patch}";
        }
    } else {
        return false;
    }
}
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:27,代码来源:image_processing.php

示例14: get_page_count

function get_page_count($resource,$alternative=-1)
    {
    # gets page count for multipage previews from resource_dimensions table.
    # also handle alternative file multipage previews by switching $resource array if necessary
    # $alternative specifies an actual alternative file
    $ref=$resource['ref'];
    if ($alternative!=-1)
        {
        $pagecount=sql_value("select page_count value from resource_alt_files where ref=$alternative","");
        $resource=get_alternative_file($ref,$alternative);
        }
    else
        {
        $pagecount=sql_value("select page_count value from resource_dimensions where resource=$ref","");
        }
    if ($pagecount!=""){return $pagecount;}
    # or, populate this column with exiftool (for installations with many pdfs already previewed and indexed, this allows pagecount updates on the fly when needed):
    # use exiftool. 
    # locate exiftool
    $exiftool_fullpath = get_utility_path("exiftool");
    if ($exiftool_fullpath==false){}
    else
        {
        $command = $exiftool_fullpath;
        if ($resource['file_extension']=="pdf" && $alternative==-1)
            {
            $file=get_resource_path($ref,true,"",false,"pdf");
            }
        else if ($alternative==-1)
            {
            # some unoconv files are not pdfs but this needs to use the auto-alt file
            $alt_ref=sql_value("select ref value from resource_alt_files where resource=$ref and unoconv=1","");
            $file=get_resource_path($ref,true,"",false,"pdf",-1,1,false,"",$alt_ref);
            }
        else
            {
            $file=get_resource_path($ref,true,"",false,"pdf",-1,1,false,"",$alternative);
            }
    
        $command=$command." -sss -pagecount $file";
        $output=run_command($command);
        $pages=str_replace("Page Count","",$output);
        $pages=str_replace(":","",$pages);
        $pages=trim($pages);

    if (!is_numeric($pages)){ $pages = 1; } // default to 1 page if we didn't get anything back

        if ($alternative!=-1)
            {
            sql_query("update resource_alt_files set page_count='$pages' where ref=$alternative");
            }
        else
            {
            sql_query("update resource_dimensions set page_count='$pages' where resource=$ref");
            }
        return $pages;
    }
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:58,代码来源:resource_functions.php

示例15: HookVideo_spliceViewAfterresourceactions

function HookVideo_spliceViewAfterresourceactions()
{
    global $videosplice_resourcetype, $resource, $lang, $config_windows, $resourcetoolsGT;
    if ($resource["resource_type"] != $videosplice_resourcetype) {
        return false;
    }
    # Not the right type.
    if (getval("video_splice_cut_from_hours", "") != "") {
        # Process actions
        $error = "";
        # Receive input
        $fh = getvalescaped("video_splice_cut_from_hours", "");
        $fm = getvalescaped("video_splice_cut_from_minutes", "");
        $fs = getvalescaped("video_splice_cut_from_seconds", "");
        $th = getvalescaped("video_splice_cut_to_hours", "");
        $tm = getvalescaped("video_splice_cut_to_minutes", "");
        $ts = getvalescaped("video_splice_cut_to_seconds", "");
        $preview = getvalescaped("preview", "") != "";
        # Calculate a duration, as needed by FFMPEG
        $from_seconds = $fh * 60 * 60 + $fm * 60 + $fs;
        $to_seconds = $th * 60 * 60 + $tm * 60 + $ts;
        $seconds = $to_seconds - $from_seconds;
        # Any problems?
        if ($seconds <= 0) {
            $error = $lang["error-from_time_after_to_time"];
        }
        # Convert seconds to HH:MM:SS as required by FFmpeg.
        $dh = floor($seconds / (60 * 60));
        $dm = floor(($seconds - $dh * 60 * 60) / 60);
        $ds = floor($seconds - $dh * 60 * 60 - $dm * 60);
        # Show error message if necessary
        if ($error != "") {
            ?>
			<script type="text/javascript">
			alert("<?php 
            echo $error;
            ?>
");
			</script>
			<?php 
        } else {
            # Process video.
            $ss = $fh . ":" . $fm . ":" . $fs;
            $t = str_pad($dh, 2, "0", STR_PAD_LEFT) . ":" . str_pad($dm, 2, "0", STR_PAD_LEFT) . ":" . str_pad($ds, 2, "0", STR_PAD_LEFT);
            # Establish FFMPEG location.
            $ffmpeg_fullpath = get_utility_path("ffmpeg");
            # Work out source/destination
            global $ffmpeg_preview_extension, $ref;
            if (file_exists(get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension))) {
                $source = get_resource_path($ref, true, "pre", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
            } else {
                $source = get_resource_path($ref, true, "", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
            }
            # Preview only?
            global $userref;
            if ($preview) {
                # Preview only.
                $target = get_temp_dir() . "/video_splice_preview_" . $userref . "." . $ffmpeg_preview_extension;
            } else {
                # Not a preview. Create a new resource.
                $newref = copy_resource($ref);
                $target = get_resource_path($newref, true, "", true, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
                # Set parent resource field details.
                global $videosplice_parent_field;
                update_field($newref, $videosplice_parent_field, $ref . ": " . $resource["field8"] . " [{$fh}:{$fm}:{$fs} - {$th}:{$tm}:{$ts}]");
                # Set created_by, archive and extension
                sql_query("update resource set created_by='{$userref}',archive=-2,file_extension='" . $ffmpeg_preview_extension . "' where ref='{$newref}'");
            }
            # Unlink the target
            if (file_exists($target)) {
                unlink($target);
            }
            if ($config_windows) {
                # Windows systems have a hard time with the long paths used for video generation.
                $target_ext = strrchr($target, '.');
                $source_ext = strrchr($source, '.');
                $target_temp = get_temp_dir() . "/vs_t" . $newref . $target_ext;
                $target_temp = str_replace("/", "\\", $target_temp);
                $source_temp = get_temp_dir() . "/vs_s" . $ref . $source_ext;
                $source_temp = str_replace("/", "\\", $source_temp);
                copy($source, $source_temp);
                $shell_exec_cmd = $ffmpeg_fullpath . " -y -i " . escapeshellarg($source_temp) . " -ss {$ss} -t {$t} " . escapeshellarg($target_temp);
                $output = exec($shell_exec_cmd);
                rename($target_temp, $target);
                unlink($source_temp);
            } else {
                $shell_exec_cmd = $ffmpeg_fullpath . " -y -i " . escapeshellarg($source) . " -ss {$ss} -t {$t} " . escapeshellarg($target);
                $output = exec($shell_exec_cmd);
            }
            #echo "<p>" . $shell_exec_cmd . "</p>";
            # Generate preview/thumbs if not in preview mode
            if (!$preview) {
                include_once "../include/image_processing.php";
                create_previews($newref, false, $ffmpeg_preview_extension);
                # Add the resource to the user's collection.
                global $usercollection, $baseurl;
                add_resource_to_collection($newref, $usercollection);
                ?>
				<script type="text/javascript">
				top.collections.location.href="<?php 
//.........这里部分代码省略.........
开发者ID:perryrothjohnson,项目名称:resourcespace,代码行数:101,代码来源:view.php


注:本文中的get_utility_path函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。