Pages

Sunday, February 3, 2013

Image Upload with multiple resolution


           
                $additional_image_name = rand(0,5000).$_FILES['additional_image']['name'];
                $additional_image_name_path = "images/".$additional_image_name;
                copy($_FILES['additional_image']['tmp_name'],$additional_image_name_path);
              
                $file = $additional_image_name_path;
                $img_dbname = $additional_image_name;
               

                require_once(simpleImage.php');
           
                $image = new SimpleImage();

                $dimensions = zen_get_dimension_new($file,'800','800');
                $image->load($file);
                $image->resize($dimensions['width'],$dimensions['height']);
                $image->save($file);

                $dimensions = zen_get_dimension_new($file,'400','400');
                $image->resize($dimensions['width'],$dimensions['height']);
                $filename_medium = 'medium/' . $img_dbname;
                $image->save($filename_medium);

                $dimensions = zen_get_dimension_new($file,'100','100');
                $image->resize($dimensions['width'],$dimensions['height']);
                $filename_medium = 'icons/' . $img_dbname;
                $image->save($filename_medium);

And you can download image file from "http://www.thewebsdevelopment.com/test/simpleImage.zip"


No comments: