PHP warning

Division by zero

/var/www/bigpodar/data/www/tovar2.ru/protected/models/CatalogCat.php(753)

741     }
742 
743     public static function baseUrl(){
744         return '/imgbd/';
745     }
746 
747     private static function resizeImg($from_file,$to_file=null,$width=0,$height=0,$quality=85,$jpegoptim=false)
748     {
749         try{
750             if($to_file==null) $to_file=$from_file;
751             $image=new Imagick();
752             $image->readImage($from_file);
753             $fitbyWidth = (($width/$image->getImageWidth())>($height/$image->getImageHeight())) ?true:false;
754             if($fitbyWidth){
755                 $rheight=floor(($width/$image->getImageWidth())*$image->getImageHeight());
756                 $image->resizeImage($width,$rheight,Imagick::FILTER_LANCZOS,1);
757                 if($height==0) $height=$rheight;
758                 if($image->getImageHeight()>$height){
759                     $ch=floor(($image->getImageHeight()-$height)/8);
760                     $image->cropImage($width,$height,0,$ch);
761                 }
762                 //$image->cropThumbnailImage($width,0);
763             }else{
764                 $rwidth=floor(($height/$image->getImageHeight())*$image->getImageWidth());
765                 $image->resizeImage($rwidth,$height,Imagick::FILTER_LANCZOS,1);

Stack Trace

#0
+
 /var/www/bigpodar/data/www/tovar2.ru/protected/models/CatalogCat.php(795): CatalogCat::resizeImg("/var/www/bigpodar/data/www/tovar2.ru/imgbd/2017/03/29/b83988.jpg", "/var/www/bigpodar/data/www/tovar2.ru/imgbd/2017/03/29/s83988.jpg", 200, 150, ...)
790         $file_th=self::basePath().$date.'/'.$prefix.$this->id.'.jpg';
791         $file_th_url=self::baseUrl().$date.'/'.$prefix.$this->id.'.jpg';
792         if(Controller::isTestServer()) return 'http://tovar2.ru'.$file_th_url;
793         if(file_exists($file_th)) return $file_th_url;
794         if(!file_exists($file_b)) return null;
795         if(self::resizeImg($file_b,$file_th,$width,$height,$quality,$jpegoptim)){
796             return $file_th_url;
797         }else return null;
798     }
799 
800     public function thumbB(){
#1
+
 /var/www/bigpodar/data/www/tovar2.ru/protected/models/CatalogCat.php(805): CatalogCat->thumbImg("s", 200, 150, 75)
800     public function thumbB(){
801         return $this->thumbImg('b');
802     }
803     
804     public function thumbS(){
805         return $this->thumbImg('s',200,150,75);
806     }
807     
808     public function thumbS70(){
809         return $this->thumbImg('ss',70,70);
810     }
#2
+
 /var/www/bigpodar/data/www/tovar2.ru/protected/views/libkat/pic_list.php(9): CatalogCat->thumbS()
04 <?php /* @var $item CatalogCat */ ?>
05 
06 <?php foreach($dataProvider->getData() as $item): ?>
07     <div class="one_section_product" id="product_<?php echo $item->id; ?>">
08         <div class="img_products">
09             <a style="background-image:url('<?php echo $item->thumbS(); ?>')"  class="image_product" href="/<?php echo $item->longUrl(); ?>"></a>
10             <div class="marks">
11                 <?php /*if($item->topprodaj): ?><span class="mark hit"></span><?php endif;*/ ?>
12                 <?php if($item->costrasp>$item->costrozn): ?><span class="mark share"></span><?php endif; ?>
13             </div>
14         </div>
2024-03-19 05:45:57 Apache/2.4.37 (centos) OpenSSL/1.1.1k mod_fcgid/2.3.9 PHP/7.2.24 Yii Framework/1.1.14