function get_thumb_path($path) { /* Return the relative (from root path) path to thumbnail file or empty string if file not found and support or path to file if not support if thumbnail file not exist - try to create it This function work with CLEAR path (check the path in outside the function) */ global $CFG; //realpath() can return the flase if file not exist //$thumb_file = realpath(dirname($path).DIRECTORY_SEPARATOR.$CFG->thumbDirName.DIRECTORY_SEPARATOR.basename($path)); $thumb_file = dirname($path) . DIRECTORY_SEPARATOR . $CFG->thumbDirName . DIRECTORY_SEPARATOR . basename($path); $thumb_file_path = str_replace($CFG->imgUploadDir, '', $thumb_file); // On MS Windows replace the '\' to '/' if (DIRECTORY_SEPARATOR !== '/') { $thumb_file_path = str_replace(DIRECTORY_SEPARATOR, '/', $thumb_file_path); } if (in_array(strtolower(pathinfo($path, PATHINFO_EXTENSION)), $CFG->thumbFileExt)) { if (!empty($CFG->thumbDirName) && intval($CFG->thumbWidth) > 0 && intval($CFG->thumbHeight) > 0) { // Check and create thumbnail for file if no exist if (!(file_exists($thumb_file) || $CFG->thumbAutoCreate === true && create_file_thumb($path) && file_exists($thumb_file))) { $thumb_file_path = ''; } } else { $thumb_file_path = ''; } } else { $thumb_file_path = ''; } return $thumb_file_path; }
// Resize $myImgTools->resize($resize_size[0], $resize_size[1]); } if ($flip_type !== -1) { // Flip $myImgTools->flip($flip_type); } if ($rotation_angle !== 0) { // Rotate $myImgTools->rotate($rotation_angle); } // Save the image $myImgTools->outputImage($dst_img, $CFG->imgQuality); // Create the thumbails if enabled in config if ($CFG->thumbAutoCreate === true) { create_file_thumb($dst_img); } } $last_error = $myImgTools->getLastError(); if (empty($last_error)) { echo 'OK'; } else { echo $last_error; } } /* Thumbnail creation example $myImgTools = new imgTools(); $myImgTools->setOverwrite(1); $myImgTools->setMaxImageSize(90); $myImgTools->loadImage($_GET['src']); $myImgTools->resize(90);