Пример #1
0
 }
 $img_dims = $uplo->get_img_dims();
 // save "medium" or default image but not bigger than MAX_
 if (defined('MAX_W') and defined('MAX_H')) {
     if ($uplo->imgwidth > MAX_W or $uplo->imgheight > MAX_H) {
         $stretch = new imagestretcher($fullpath);
         $stretch->shrink_to_fit(MAX_W, MAX_H);
         $stretch->save_to_file($fullpath);
         $img_dims = $stretch->get_img_dims();
         $stretch->free();
     }
 }
 // create a thumbnail right here:
 $needs_thumb = false;
 if (defined('THUMB_MAX_W') and defined('THUMB_MAX_H')) {
     $thumb1 = $uplo->save_thumbnail(THUMB_MAX_W, THUMB_MAX_H, 'shrink_to_fit');
     $needs_thumb = true;
 } elseif (defined('THUMB_EXACT_W') and defined('THUMB_EXACT_H')) {
     $thumb1 = $uplo->save_thumbnail(THUMB_EXACT_W, THUMB_EXACT_H, 'shrink_to_size');
     $needs_thumb = true;
 }
 if ($needs_thumb && empty($thumb1)) {
     $thumb1 = $newfilename;
 }
 if (PEAR::isError($thumb1)) {
     $errs[] = $thumb1->getMessage();
 } else {
     $vals['system_location'] = CSHOP_MEDIA_URLPATH;
     $vals['filename_large'] = $newfilename;
     $vals['dims_large'] = $img_dims;
     $vals['filename_thumb'] = $thumb1;
Пример #2
0
         $uplo->unique_filename = true;
         $uplo->preserve_original_name = true;
         $uplo->setErrorHandling(PEAR_ERROR_RETURN);
         // tell $uplo what kind of image we expect and where to put it:
         $uplo->params = $colmap[$upfile][3];
         $res = $uplo->save_upload();
         if (PEAR::isError($res)) {
             $errs[] = $res->getMessage();
         } else {
             // get the name of the new file
             $newfilename = $uplo->get_newname();
             // vals to be put in DB
             $upfiles[$upfile] = array('sFilename' => $newfilename, 'sType' => 'image', 'dtDate' => date('Y-m-d h:i'), 'img_dims' => $uplo->get_img_dims());
             if ($upfile == 'imageid') {
                 // create a thumbnail right here:
                 $thumb1 = $uplo->save_thumbnail(THUMB_MAX_W, THUMB_MAX_H);
                 if (PEAR::isError($thumb1)) {
                     $errs[] = $thumb1->getMessage();
                 } else {
                     // another upfile for the thumbnail image
                     $upfiles['image_thumbid'] = array('sFilename' => $thumb1, 'sType' => 'image', 'dtDate' => date('Y-m-d h:i'), 'img_dims' => $uplo->get_thumb_dims());
                 }
             }
         }
     }
 }
 $imgcount = 0;
 /** try to insert or update image info to DB table media_prod **/
 foreach ($upfiles as $upfile => $img_vals) {
     if (count($img_vals)) {
         $imgcount++;