/** * Create a JPEG thumbnail for the given png/gif/jpeg image and return the path to the new image . * * @param string $file the file path to the image * @param int $width the width * @param int $height the height * @param int $quality of image thumbnail * @return string */ public static function thumb($file, $width = 80, $height = 80, $quality = 80, $center = true) { if (!file_exists($file)) { return false; } $path_parts = pathinfo($file); $dir = $path_parts['dirname']; $name = $path_parts['filename'] . "_{$width}-{$height}.jpg"; $new_file = $dir . W_DS . $name; // If the thumbnail already exists, we can't write to the directory, or the image file is invalid if (file_exists($new_file)) { return $new_file; } if (!directory_is_writable($dir)) { return false; } $image = self::open($file); //dump($image, $file);exit(); if (!$image) { return false; } // Resize the image and save it as a compressed JPEG $obj = self::resize($image, $width, $height, $center); if (imagejpeg($obj, $new_file, $quality)) { return $new_file; } return false; }
/** * Create a JPEG thumbnail for the given png/gif/jpeg image and return the path to the new image . * * @param string $file the file path to the image * @param int $width the width * @param int $height the height * @param int $quality of image thumbnail * @return string */ public static function thumbnail($file, $width = 80, $height = 80, $quality = 80) { if (!is_file($file)) { return; } $dir = "Public/Uploads/Thumbnails/{$width}-x-{$height}/"; $name = basename($file) . '.jpg'; // If the thumbnail already exists, we can't write to the directory, or the image file is invalid if (is_file(SP . $dir . $name)) { return $dir . $name; } if (!directory_is_writable(SP . $dir) or !($image = self::open($file))) { return; } // Resize the image and save it as a compressed JPEG if (imagejpeg(self::resize($image, $width, $height), SP . $dir . $name, $quality)) { return $dir . $name; } }
$table[] = '<b>/file/</b> ' . IP_WRITABLE . ' ' . IP_SUBDIRECTORIES; if (!directory_is_writable(dirname(__FILE__) . '/../file')) { $table[] = '<span class="error">' . IP_ERROR . "</span>"; $error['writable_file'] = 1; } else { $table[] = '<span class="correct">' . IP_OK . '</span>'; } $table[] = '<b>/image/</b> ' . IP_WRITABLE . ' ' . IP_SUBDIRECTORIES; if (!directory_is_writable(dirname(__FILE__) . '/../image')) { $table[] = '<span class="error">' . IP_ERROR . "</span>"; $error['writable_image'] = 1; } else { $table[] = '<span class="correct">' . IP_OK . '</span>'; } $table[] = '<b>/video/</b> ' . IP_WRITABLE . ' ' . IP_SUBDIRECTORIES; if (!directory_is_writable(dirname(__FILE__) . '/../video')) { $table[] = '<span class="error">' . IP_ERROR . "</span>"; $error['writable_video'] = 1; } else { $table[] = '<span class="correct">' . IP_OK . '</span>'; } $table[] = '<b>/ip_config.php</b> ' . IP_WRITABLE; if (!is_writable(dirname(__FILE__) . '/../ip_config.php')) { $table[] = '<span class="error">' . IP_ERROR . "</span>"; $error['writable_config'] = 1; } else { $table[] = '<span class="correct">' . IP_OK . '</span>'; } $table[] = '<b>/robots.txt</b> ' . IP_WRITABLE; if (!is_writable(dirname(__FILE__) . '/../robots.txt')) { $table[] = '<span class="error">' . IP_ERROR . "</span>";