Witajcie.
Przeszukuję manual do biblioteki GD2, jednak nijak nie potrafię znaleźć funkcji odpowiadającej za stworzenie lustrzanego odbicia fotki. Istnieje taka możliwość?
<?php $im = imagecreatefromjpeg($address); $width = imagesx($im); $height = imagesy($im); if($im2 = imagecreatetruecolor($width, $height)) { for($i = 0; $i < $height; $i++) { imagecopy($im2, $im, 0, $height-$i-1, 0, $i, $width, 1); } imagejpeg($im2); imagedestroy($im); imagedestroy($im2); } } ?>
if($request->hasParameter('src')){ if($request->hasParameter('type')) $type = $request->getParameter('type'); else $type=1; $img = imagecreatefromjpeg( '.'.$request->getParameter('src') ); if($type==1) imagefilter($img, IMG_FILTER_GRAYSCALE); if($type==2) imagefilter($img, IMG_FILTER_NEGATE); if($type==3){ imagefilter($img, IMG_FILTER_GRAYSCALE); imagefilter($img, IMG_FILTER_COLORIZE, 90, 60, 40); } if($type==4){ $szerokosc = imagesx($img); $wysokosc = imagesy($img); $img2 = imagecreatetruecolor($szerokosc, $wysokosc); for ($x=0;$x<$szerokosc;$x++) { for ($y=0;$y<$wysokosc;$y++) { $imgColor = imagecolorat( $img, $szerokosc-$x-1, $y-1 ); // odbicie w poziomie imagesetpixel($img2, $x, $y, $imgColor); } } imagejpeg($img2, '', 100); $img=$img2; }
<?php class productActions extends sfActions { public function executeShow(sfWebRequest $request) { $this->cfg = Doctrine_Query::create()->from('Config c')->fetchOne(); $this->forward404Unless($this->product); $this->menuTop = Doctrine_Query::create() ->from('Menus') ->where('location="top" OR location=""') ->orderBy('nr ASC') ->execute(); $this->menuBot = Doctrine_Query::create() ->from('Menus') ->where('location="bottom"') ->orderBy('nr ASC') ->execute(); } public function executeAjax_filter(sfWebRequest $request) { //if($request->IsXmlHttpRequest()){ if($request->hasParameter('src')){ if($request->hasParameter('type')) $type = $request->getParameter('type'); else $type=1; $img = imagecreatefromjpeg( '.'.$request->getParameter('src') ); if($type==1) imagefilter($img, IMG_FILTER_GRAYSCALE); if($type==2) imagefilter($img, IMG_FILTER_NEGATE); if($type==3){ imagefilter($img, IMG_FILTER_GRAYSCALE); imagefilter($img, IMG_FILTER_COLORIZE, 90, 60, 40); } if($type==4){ $szerokosc = imagesx($img); $wysokosc = imagesy($img); $img2 = imagecreatetruecolor($szerokosc, $wysokosc); for ($x=0;$x<$szerokosc;$x++) { for ($y=0;$y<$wysokosc;$y++) { $imgColor = imagecolorat( $img, $szerokosc-$x-1, $y-1 ); // odbicie w poziomie imagesetpixel($img2, $x, $y, $imgColor); } } imagejpeg($img2, '', 100); } imagejpeg($img); return sfView::NONE; } //} //else $this->forward404(); } public function executeAjax_crop(sfWebRequest $request) { if($request->hasParameter('src')){ $filename = '.'.$request->getParameter('src'); // cropping $fx = 0.0; $fy = 0.0; $fw = 1.0; $fh = 1.0; if($request->hasParameter('f_x')) $fx = $request->getParameter('f_x'); if($request->hasParameter('f_y')) $fy = $request->getParameter('f_y'); if($request->hasParameter('f_w')) $fw = $request->getParameter('f_w'); if($request->hasParameter('f_h')) $fh = $request->getParameter('f_h'); // filter type if($request->hasParameter('type')) $type = $request->getParameter('type'); else $type=0; // Content type // Get new dimensions $new_width = $width * $fw; $new_height = $height * $fh; // Resample $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); // filtering if($type==1) imagefilter($image, IMG_FILTER_GRAYSCALE); if($type==2) imagefilter($image, IMG_FILTER_NEGATE); if($type==3){ imagefilter($image, IMG_FILTER_GRAYSCALE); imagefilter($image, IMG_FILTER_COLORIZE, 90, 60, 40); } imagecopyresampled($image_p, $image, $fx*$width,$fy*$height, 0,0 , $width, $height, $width, $height); // Output imagejpeg($image_p, null, 100); } return sfView::NONE; } public function executeAjax_help(sfWebRequest $request) { @$type = $request->getParameter('type'); if($type=='mat'){ $materials = Doctrine_Query::create()->from('Materials m')->execute(); $c=0; foreach($materials as $mat){ $res[$c++] = Array('name' => $mat->getName(), 'desc' => $mat->getDescription(), 'photo' => $mat->getPhoto()); } $this->renderText(json_encode($res)); } if($type=='prod'){ $tproducts = Doctrine_Query::create()->from('TypeProducts tp')->execute(); $c=0; foreach($tproducts as $tp){ $res[$c++] = Array('name' => $tp->getName(), 'desc' => $tp->getDescription(), 'photo' => $tp->getPhoto()); } $this->renderText(json_encode($res)); } return sfView::NONE; } public function executePageNotFound(){ } }
imagejpeg($img2, '', 100);
$img = $img2;
<?php class productActions extends sfActions { public function executeShow(sfWebRequest $request) { $this->cfg = Doctrine_Query::create()->from('Config c')->fetchOne(); $this->forward404Unless($this->product); $this->menuTop = Doctrine_Query::create() ->from('Menus') ->where('location="top" OR location=""') ->orderBy('nr ASC') ->execute(); $this->menuBot = Doctrine_Query::create() ->from('Menus') ->where('location="bottom"') ->orderBy('nr ASC') ->execute(); } public function executeAjax_filter(sfWebRequest $request) { //if($request->IsXmlHttpRequest()){ if($request->hasParameter('src')){ if($request->hasParameter('type')) $type = $request->getParameter('type'); else $type=1; $img = imagecreatefromjpeg( '.'.$request->getParameter('src') ); if($type==1) imagefilter($img, IMG_FILTER_GRAYSCALE); if($type==2) imagefilter($img, IMG_FILTER_NEGATE); if($type==3){ imagefilter($img, IMG_FILTER_GRAYSCALE); imagefilter($img, IMG_FILTER_COLORIZE, 90, 60, 40); } if($type==4)imageflip($img, IMG_FLIP_HORIZONTAL); imagejpeg($img); return sfView::NONE; } //} //else $this->forward404(); } public function executeAjax_crop(sfWebRequest $request) { if($request->hasParameter('src')){ $filename = '.'.$request->getParameter('src'); // cropping $fx = 0.0; $fy = 0.0; $fw = 1.0; $fh = 1.0; if($request->hasParameter('f_x')) $fx = $request->getParameter('f_x'); if($request->hasParameter('f_y')) $fy = $request->getParameter('f_y'); if($request->hasParameter('f_w')) $fw = $request->getParameter('f_w'); if($request->hasParameter('f_h')) $fh = $request->getParameter('f_h'); // filter type if($request->hasParameter('type')) $type = $request->getParameter('type'); else $type=0; // Content type // Get new dimensions $new_width = $width * $fw; $new_height = $height * $fh; // Resample $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); // filtering if($type==1) imagefilter($image, IMG_FILTER_GRAYSCALE); if($type==2) imagefilter($image, IMG_FILTER_NEGATE); if($type==3){ imagefilter($image, IMG_FILTER_GRAYSCALE); imagefilter($image, IMG_FILTER_COLORIZE, 90, 60, 40); } if($type==4)imageflip($imgage, IMG_FLIP_HORIZONTAL); imagecopyresampled($image_p, $image, $fx*$width,$fy*$height, 0,0 , $width, $height, $width, $height); // Output imagejpeg($image_p, null, 100); } return sfView::NONE; } public function executeAjax_help(sfWebRequest $request) { @$type = $request->getParameter('type'); if($type=='mat'){ $materials = Doctrine_Query::create()->from('Materials m')->execute(); $c=0; foreach($materials as $mat){ $res[$c++] = Array('name' => $mat->getName(), 'desc' => $mat->getDescription(), 'photo' => $mat->getPhoto()); } $this->renderText(json_encode($res)); } if($type=='prod'){ $tproducts = Doctrine_Query::create()->from('TypeProducts tp')->execute(); $c=0; foreach($tproducts as $tp){ $res[$c++] = Array('name' => $tp->getName(), 'desc' => $tp->getDescription(), 'photo' => $tp->getPhoto()); } $this->renderText(json_encode($res)); } return sfView::NONE; } public function executePageNotFound(){ } }
// filtering if($type==1) imagefilter($image, IMG_FILTER_GRAYSCALE); if($type==2) imagefilter($image, IMG_FILTER_NEGATE); if($type==3){ imagefilter($image, IMG_FILTER_GRAYSCALE); imagefilter($image, IMG_FILTER_COLORIZE, 90, 60, 40); } if($type==4)imageflip([color="#FF0000"]$image[/color], IMG_FLIP_HORIZONTAL); imagecopyresampled($image_p, $image, $fx*$width,$fy*$height, 0,0 , $width, $height, $width, $height); // Output imagejpeg($image_p, null, 100);