parser

Написать ответ на текущее сообщение

 

 
   команды управления поиском

Ответ

GoodVin 13.08.2004 16:13 / 13.08.2004 16:15

Переделанный код класса из примера:
images.p
@resize[params][$script_path]
^if(def $params && $params is "hash"){
	^if(!def $params.destination_path){$params.destination_path[$params.source_path]}
	^if(!def $params.x_size){$params.x_size(100)}
	^if(def $params.image_name){
		$f[^file::exec[$params.script_path/convert;;$params.source_path/$params.image_name;-resize;$params.x_size;-colorspace;RGB;+profile;"*";$params.destination_path/$params.image_name]]
		^if($f.status > 0){
			^throw[exec.error;ImageMagick.Convert.Exec;$f.stderr]    
		}
		$result(0)
	}{
		$result(1)
	}
}{
	$result(2)
}
вызов метода из .html:
<form method="POST" action="$request:uri" enctype="multipart/form-data">
<br />
Картинка: <input type="file" name="pict" size="50" /> 
<br /><br />
Ширина картинки: <input type="text" name="size" value="^if(def $form:size){$form:size}{200}" size="5" maxlength="10">
<input type="submit" value="создать" />
</form>

$source_path[../img/rest]
$destination_path[../img/rest/small]

^if(def $form:pict && $form:pict is "file"){
	$x_size(^form:size.int(100))
	$extension[^file:justext[$form:pict.name]]
	$image_name[1.^extension.lower[]]
	^if(!^images:save[$form:pict;$source_path;$image_name]){
		^images:resize[
			$.script_path[/../exec]
			$.source_path[$source_path]
			$.destination_path[$destination_path]
			$.image_name[$image_name]
			$.x_size[$x_size]
		]
		$response:refresh[ $.value[0] $.url[$request:uri] ]
	}{
		Файл не сохранен&hellip^;
	}
}{                                           
	Заполните все поля формы&hellip^;
}    
файл convert.exe лежит в:
/www/../exec/

web-сервер на Windows Server 2003 + Apache