$JpegQuality = 85;
if (!empty($this->Width) and !empty($this->Height))
{
if (true == $this->CropHorizontally)
{
$Command =
'convert' .
// ' -size ' . ($this->Width * 3) . 'x' . ($this->Height * 3) .
// ' ' . str_replace('/', '\\', $this->InputFile) .
' "' . str_replace('/', '\\', $this->InputFile) . '"' .
' -thumbnail x' .($this->Height * 2) .
' -resize "' . ($this->Width * 2) . 'x<"' .
' -resize 50%' .
// ' -gravity north' .
' -crop ' . $this->Width . 'x' . $this->Height . '+0+0' .
' +repage -quality ' . $JpegQuality .
' "' . str_replace('/', '\\', $this->OutputFile) . '"'
;
}
elseif (true === $this->CropVertically)
{
$Command =
'convert' .
// ' -size ' . ($this->Width * 3) . 'x' . ($this->Height * 3) .
// ' ' . str_replace('/', '\\', $this->InputFile) .
' "' . str_replace('/', '\\', $this->InputFile) . '"' .
' -thumbnail ' .($this->Width * 2) . 'x' .
' -resize "x' . ($this->Heigth * 2) . '<"' .
' -resize 50%' .
// ' -gravity north' .
' -crop ' . $this->Width . 'x' . $this->Height . '+0+0' .
' +repage -quality ' . $JpegQuality .
' -interlace Line ' .
' "' . str_replace('/', '\\', $this->OutputFile) . '"'
;
}
elseif (true === $this->FillBlankArea)
{
$Command =
'convert ' .
// ' \(' .
'"' . str_replace('/', '\\', $this->InputFile) . '"' .
' -resize "' . ($this->Width) . 'x' . ($this->Height) .'" ' .
// ' \)' .
// ' \(' .
' -size "' . ($this->Width) . 'x' . ($this->Height) . '" ' .
' xc:white' .
// ' \)' .
' +swap' .
' -gravity center' .
' -composite' .
// ' -compose over' .
// ' -quality ' . $JpegQuality . ' ' .
' -interlace Line ' .
' "' . str_replace('/', '\\', $this->OutputFile) . '"' .
'';
}
else
{
$Command =
'convert' .
// ' -size ' . ($this->Width * 3) . 'x' . ($this->Height * 3) .
// ' ' . str_replace('/', '\\', $this->InputFile) .
' "' . str_replace('/', '\\', $this->InputFile) . '"' .
' -thumbnail "' . $this->Width . 'x' . $this->Height .'>"' .
// ' -resize "' . ($this->Width * 2) . 'x<"' .
// ' -resize 50%' .
' -gravity north' .
// ' -crop ' . $this->Width . 'x' . $this->Height . '+0+0' .
' +repage -quality ' . $JpegQuality .
' -interlace Line ' .
' "' . str_replace('/', '\\', $this->OutputFile) . '"'
;
}
}
else
{
$Command =
'convert ' .
// '-size ' . ($this->Width) . 'x' . ($this->Height) .' ' .
'-resize ' . ($this->Width) . 'x' . ($this->Height) .' ' .
'-quality ' . $JpegQuality . ' ' .
' "' . str_replace('/', '\\', $this->InputFile) . '"' .
' -interlace Line ' .
' "' . str_replace('/', '\\', $this->OutputFile) . '"';
}
// print $Command =
// 'convert' .
// ' -size ' . ($this->Width) . 'x' . ($this->Height) .' ' . str_replace('/', '\\', $this->InputFile) .
// ' -thumbnail "' . $this->Width . 'x' . $this->Height .'>"' .
// ' -bordercolor skyblue' .
// ' -border 50' .
// ' -gravity center' .
// ' -crop ' . $this->Width . 'x' . $this->Height .'+0+0' .
// ' +repage ' . str_replace('/', '\\', $this->OutputFile)
// ;
// $Command =
// 'montage ' .
// '-background #ffffff ' .
// '-resize ' . $this->Width . 'x' . $this->Height .' ' .
// str_replace('/', '\\', $this->InputFile) . ' ' .
// str_replace('/', '\\', $this->OutputFile);
$Command = str_replace('\\', DIRECTORY_SEPARATOR, $Command);
print $Command . "\n<br />";
print exec($Command);
/* Add redirection so we can get stderr. */
// $handle = popen($Command, 'r');
// echo "'$handle'; " . gettype($handle) . "\n";
// $read = fread($handle, 2096);
// echo $read;
// pclose($handle);
$this->DebugOutput = ob_get_clean();
}
protected function alignVertically($Style, &$ImagePath)
{
// print '$this->Src'."\n";
// print_r($this->Src);
//
// print '$this->Dest'."\n";
// print_r($this->Dest);
//
// print '$ImagePath[Size][1] :: ' . $this->Src->GIS[1] ."\n";
// print '$this->Src->Height :: ' . $this->Src->Height ."\n";
// print '$this->Src->Y :: ' . $this->Src->Y ."\n";
switch ($Style)
{
case 'center' :
// $HeightToCompose = $this->Src->GIS[1] / 2 - $this->Src->Height / 2;
// $this->Src->Y = $this->Src->Y - $HeightToCompose / 2;
$this->Src->Y = $this->Src->GIS[1] / 2 - $this->Src->Height / 2;
break;
}
// print '$HeightToCompose :: ' . $HeightToCompose ."\n";
// print '$this->Src->Height :: ' . $this->Src->Height ."\n";
// print '$this->Src->Y :: ' . $this->Src->Y ."\n";
}