Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2014
    Location
    Bronx, New York, United States
    Posts
    83
    Plugin Contributions
    0

    Default Resize Image While Uploading

    i want to Resize Image While Uploading 400*400 px


    i saw that code on a website
    don't know how to do that

    plz help

    PHP Code:
    /**
     * Image resize
     * @param int $width
     * @param int $height
     */
    function resize($width$height){
      
    /* Get original image x y*/
      
    list($w$h) = getimagesize($_FILES['image']['tmp_name']);
      
    /* calculate new image size with ratio */
      
    $ratio max($width/$w$height/$h);
      
    $h ceil($height $ratio);
      
    $x = ($w $width $ratio) / 2;
      
    $w ceil($width $ratio);
      
    /* new file name */
      
    $path 'uploads/'.$width.'x'.$height.'_'.$_FILES['image']['name'];
      
    /* read binary data from image file */
      
    $imgString file_get_contents($_FILES['image']['tmp_name']);
      
    /* create image from string */
      
    $image imagecreatefromstring($imgString);
      
    $tmp imagecreatetruecolor($width$height);
      
    imagecopyresampled($tmp$image,
        
    00,
        
    $x0,
        
    $width$height,
        
    $w$h);
      
    /* Save image */
      
    switch ($_FILES['image']['type']) {
        case 
    'image/jpeg':
          
    imagejpeg($tmp$path100);
          break;
        case 
    'image/png':
          
    imagepng($tmp$path0);
          break;
        case 
    'image/gif':
          
    imagegif($tmp$path);
          break;
        default:
          exit;
          break;
      }
      return 
    $path;
      
    /* cleanup memory */
      
    imagedestroy($image);
      
    imagedestroy($tmp);


  2. #2
    Join Date
    Dec 2010
    Location
    UK
    Posts
    1,771
    Plugin Contributions
    3

    Default Re: Resize Image While Uploading

    What is it exactly you're looking to do, is it for your product images? Have you tried the image handler mod?

  3. #3
    Join Date
    Apr 2014
    Location
    Bronx, New York, United States
    Posts
    83
    Plugin Contributions
    0

    Default Re: Resize Image While Uploading

    Quote Originally Posted by picandnix View Post
    What is it exactly you're looking to do, is it for your product images? Have you tried the image handler mod?
    look, i need to add many product regularly and condition is all product should 400*400 px

    so i want when i add a new product whatever size i upload i will be automatic convert 400*400 px


    i installed image handler its not do it automatically.

  4. #4
    Join Date
    Dec 2010
    Location
    UK
    Posts
    1,771
    Plugin Contributions
    3

    Default Re: Resize Image While Uploading

    Quote Originally Posted by jennydutch View Post
    look, i need to add many product regularly and condition is all product should 400*400 px

    so i want when i add a new product whatever size i upload i will be automatic convert 400*400 px


    i installed image handler its not do it automatically.
    I use this for all my sites and images, works perfectly, and fast. You can set image size and optimize all in one swoop.

  5. #5
    Join Date
    Apr 2014
    Location
    Bronx, New York, United States
    Posts
    83
    Plugin Contributions
    0

    Default Re: Resize Image While Uploading

    Quote Originally Posted by picandnix View Post
    I use this for all my sites and images, works perfectly, and fast. You can set image size and optimize all in one swoop.
    Thanks going to download :)

  6. #6
    Join Date
    Dec 2010
    Location
    UK
    Posts
    1,771
    Plugin Contributions
    3

    Default Re: Resize Image While Uploading

    Quote Originally Posted by jennydutch View Post
    Thanks going to download :)
    Let me know how you get with it.

  7. #7
    Join Date
    Apr 2014
    Location
    Bronx, New York, United States
    Posts
    83
    Plugin Contributions
    0

    Default Re: Resize Image While Uploading

    Quote Originally Posted by picandnix View Post
    Let me know how you get with it.
    right now i am doing this manually

  8. #8
    Join Date
    Jan 2007
    Location
    Los Angeles, California, United States
    Posts
    10,023
    Plugin Contributions
    32

    Default Re: Resize Image While Uploading

    Quote Originally Posted by jennydutch View Post
    i installed image handler its not do it automatically.
    it most certainly does do the resizing automatically based on your admin image settings.. HOWEVER, your SOURCE image must be equal dimensions if you expect it to be resized in equal dimensions. So if you have a 1024 x 1024 image and you set your large image settings to 400 x 400, then IH4 most DEFINITELY will resize the image as you expect.. However if your source image is 1024 x 800 IH will resize PROPORTIONALLY based on your image size settings.
    My Site - Zen Cart & WordPress integration specialist
    I don't answer support questions via PM. Post add-on support questions in the support thread. The question & the answer will benefit others with similar issues.

 

 

Similar Threads

  1. v150 image resize
    By maperr55 in forum General Questions
    Replies: 11
    Last Post: 5 Feb 2016, 02:28 PM
  2. IH2 Image Handler 2 Won't Resize Main Image
    By limelites in forum General Questions
    Replies: 4
    Last Post: 14 Jun 2009, 11:32 AM
  3. Resize Image
    By Talen in forum General Questions
    Replies: 3
    Last Post: 14 Dec 2008, 04:43 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR