SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    resize the image and overwrite it

    hay guys well i usually read that we can upload and resize it into another size and that is fine but what if i want to add another level like
    the picture is 1600x1400 and i want to resize it into 800x600 and overwrite it and after i overwrite it i want to create a new on with the size less than the 800x600 is this possible

    can i overwrite a resized image ?????
    and can i just resize also this resized image ????????

  2. #2
    SitePoint Enthusiast onion2k's Avatar
    Join Date
    Dec 2005
    Location
    UK
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can just resize an image that you've already resized, but every time you do the quality will get lower. If you need to have a few different sized versions of the same image it's much better to generate them all from the original, and then overwrite the original with whatever you want as your final operation.

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2005
    Posts
    97
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well here is the same thing iam sayin but its aint working its just resizing it to the small size and the 360 size is not workin its kept the same original size :S
    PHP Code:
    $destimg=ImageCreateTrueColor(360,240) or die('Problem In Creating image');
    if(
    $userfile_type=="image/gif")
            
    $srcimg=ImageCreateFromgif($prod_img) or die('Problem In opening Source Image');
    if(
    $userfile_type=="image/pjpeg")
            
    $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image');
            
    imagecopyresampled($destimg,$srcimg,0,0,0,0,360,240,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
            
    ImageJPEG($destimg,$prod_img_thumb,90) or die('Problem In saving');
            
    imagedestroy($destimg);
    //------------------------------------

        
    $maxwidth=120;
        
    $new_height80;

            
    $destimg=ImageCreateTrueColor($maxwidth,$new_height) or die('Problem In Creating image');
    if(
    $userfile_type=="image/gif")
            
    $srcimg=ImageCreateFromgif($prod_img) or die('Problem In opening Source Image');
    if(
    $userfile_type=="image/pjpeg")
            
    $srcimg=ImageCreateFromJPEG($prod_img) or die('Problem In opening Source Image');
            
    imagecopyresampled($destimg,$srcimg,0,0,0,0,$maxwidth,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing');
            
    ImageJPEG($destimg,$prod_img_thumb,90) or die('Problem In saving');
            
    imagedestroy($destimg);
     
    $query=" INSERT INTO IMAGE (ID,Items_ID,image_type,image_size,image_name,thumb_name,image_date) VALUES ('','".$_SESSION['items_id']."','$userfile_type','$userfile_size','$userfile_name','$thumb_name','$time_in')";
    mysql_query($query) or die('Error !!'.mysql_error());

        } 

  4. #4
    SitePoint Enthusiast onion2k's Avatar
    Join Date
    Dec 2005
    Location
    UK
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When you're saving the second file you're using $prod_img_thumb as the filename. That should be $prod_img. Also, check your source and destination image variables are the right way round in the imagecopyresampled() functions .. I'm not sure if you've got them the wrong way round or if you've used odd variable names..


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
  •