Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- header('Content-Type: image/png');
- $file = "/home/thomedy/Desktop/images/pic.png";
- class featured_designer_resize
- {
- public $old_height;
- public $old_width;
- public $old_image;
- private $old_image_path = array();
- public $image_canvas;
- public $new_height;
- public $new_width;
- public $new_image;
- private $new_image_path = array();
- public $img;
- public $file_ext;
- public $by_eight;
- public function __construct($featured_designer) {
- $this->by_eight = 8;
- $old_designer_query = 'select featured_name from {your_featured_designer} limit 0, 1';
- // $old_designer . '_thumbs');
- // $old_designer_results = db_query($old_designer_query);
- $old_designer = '';
- /* while($row = db_fetch_array($old_designer_results)) {
- $old_designer = $row['featured_name'];
- }
- */
- if(is_dir($old_designer . '_thumbs')) {
- //***** check for old designer thumbs and clear the old thumbs ****//
- chdir($old_designer . '_thumbs');
- foreach(glob('*') as $f) if (is_file($f)) unlink($f);
- chdir('..');
- rmdir($old_designer . '_thumbs');
- //***** create new designer directory for thumbs ****//
- mkdir($featured_designer . '_thumbs');
- }
- else {
- //***** create new designer directory for thumbs ****//
- mkdir($featured_designer . '_thumbs');
- }
- }
- public function featured_designer_get_image_extension($file) {
- //****** remove extension to check which image type *******//
- $this->file_ext = strrchr($file, '.');
- }
- public function featured_designer_get_image_size($filename) {
- list($width, $height) = getimagesize($filename);
- $this->old_width = $width;
- $this->old_height = $height;
- }
- public function featured_designer_set_new_image_size() {
- $this->new_width = $this->old_width / $this->by_eight;
- $this->new_height = $this->old_height / $this->by_eight;
- }
- public function featured_designer_create_both_images($file) {
- $this->old_image = imagecreatetruecolor(75, 100);
- if ($this->file_ext == '.jpg' || $file_ext == 'jpeg') {
- $this->img = imagecreatefromjpeg($file);
- }
- else if ($this->file_ext == '.png') {
- $this->img = imagecreatefrompng($file);
- }
- else if ($this->file_ext == '.gif') {
- $this->img = imagecreatefrompng($file);
- }
- else {
- $this->img = FALSE;
- }
- }
- public function featured_designer_create_image() {
- imagecopyresampled($this->old_image, $this->img, 0, 0, 0, 0, 75, 100, $old_width, $old_height);
- }
- public function featured_designer_output_image() {
- if ($this->file_ext == '.jpg' || $this->file_ext == 'jpeg') {
- return imagejpeg($this->old_image);
- }
- else if ($this->file_ext == '.png') {
- return imagepng($this->old_image);
- }
- else if ($this->file_ext == '.gif') {
- return imagegif($this->old_image);
- }
- else {
- return FALSE;
- }
- }
- public function featured_designer_image_destroy() {
- imagedestroy($this->old_image);
- }
- }
- $test = new featured_designer_resize('me');
- $test -> featured_designer_get_image_extension('/home/thomedy/Desktop/images/pic.jpg');
- $test -> featured_designer_get_image_size('/home/thomedy/Desktop/images/pic.jpg');
- $test -> featured_designer_set_new_image_size();
- $test -> featured_designer_create_both_images('/home/thomedy/Desktop/images/pic.jpg');
- $test -> featured_designer_output_image('/home/thomedy/Desktop/images/pic.jpg');
- $test -> featured_designer_image_destroy();
- //var_dump($test);
- ?>
Add Comment
Please, Sign In to add comment