SitePoint Sponsor

User Tag List

Page 5 of 6 FirstFirst 123456 LastLast
Results 101 to 125 of 139
  1. #101
    Anonymous
    SitePoint Community Guest
    Not working... Have add the include.

  2. #102
    Rakesh Muraharishetty
    SitePoint Community Guest
    $mysize = getimagesize("images/sock001.jpg");
    echo "<img src=\"images/sock001.jpg\";
    if ($mysize[0] > $mysize[1]) {
    $percentage = (60 / $mysize[0]);
    } else {
    $percentage = (75 / $mysize[1]);
    }
    $width = round($mysize[0] * $percentage);
    $height = round($mysize[1] * $percentage);
    echo "style=\"width:".$width."px; height:".$height."px\"";
    echo " class=\"th\"></a>";

    Hope this should solve it

  3. #103
    Ryan Malone
    SitePoint Community Guest
    I'm trying to use this to change my thumbs to a set size of W:160 H:120 (landscape) and W:120 L:160 (portrait) but every time I upload it makes my website blank.

    Where should the getimagesize() command be implemented if I want to use it to get all image sizes?

    I'm lost! Thanks for any help...

  4. #104
    SitePoint Addict
    Join Date
    Jul 2007
    Location
    San Jose, California
    Posts
    355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  5. #105
    Ummm
    SitePoint Community Guest
    This is a horrible example... You aren't actually making thumbnails, you are still sending the full size image and having the browser resize it.. BS sitepoint!

  6. #106
    nuh uh
    SitePoint Community Guest
    I keep reading it, and nowhere does it ever use php to resize an image. I agree with Ummm.

    All this does is use php to tell you how large your images already are!

    I further don't believe that this article was published in 2003 but went 5 years before anyone commented on it.

  7. #107
    Giancarlo
    SitePoint Community Guest
    I was looking for such a code.

    About the datatraffic. On my site I use the image in several dimensions. On the homepage I have a Flash news scroller/reader with a relatively large dimensions (a).
    In the newsposts below I use a rather smaller image (b). When posting a newsitem in the admin it uploads the image to the server twice according the dimansions a and b.
    I also use a 3rd dimension of the image on the archive page. I do not want to upload the image in 3 different dimensions via the admin. So I use the code above to resize the image (with dimensions b) to this 3rd dimension.

    The datatraffic isn't that bad. The site wherefor I'm using it attracts 1000+ unique visitors and this seems to be the best solution.

  8. #108
    Roy Vincent
    SitePoint Community Guest
    This is a horrible example of php image resizer I have ever read in my entire life...
    this example can simply be applied with just using css.... lolx!

  9. #109
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i am amazed to see the reply of some members here
    i am not sure if u guys understand the need for image resizing.

    yes no doubt css or hard code can resize. BUT WHAT IF THE IMAGE are not symetrical? example

    100x100 can out put at 100x100 , fine. nice

    400x400. can out put as 100x100.excellent.

    what abt

    400x200?? this is the situation u need a script. if u use the css ul get a distorted 100x100 image that make ur visitor jump to alt site.

    then how abt the quality ?

    the script does this for you.
    find and det3ect the x n y value n perform some percentage calc and resize the image for you.

    the output will be a max width of you specified image with diff height variations that look clean for website without loss of quality or distortions.

  10. #110
    SitePoint Member
    Join Date
    Oct 2007
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyway on the sitenote

    how do i resize the fetched rss image size?
    rss images are not stored on db, it comes n go as the updates.

    so how do i use image resizing to display nicely layout with max width of 100px images?

    tks

  11. #111
    Garr
    SitePoint Community Guest
    The script manages ratios the way it should, but you should not be resizing your images in your HTML! That's the big thing here. With the image functions available in PHP, you can dynamically create a new, temporary image just for the display of the needed use. Otherwise, you're still downloading the FULL SIZE image and the browser is manipulating it via deprecated standards. Bad form. GREAT IDEA. A little more effort into the image library and this would be awesome.

  12. #112
    SitePoint Member
    Join Date
    Nov 2007
    Location
    North East England
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, this is a good script, simple to use and it's a good base for building a more tailored solution.
    As many people have pointed out this resizes the image and it mixes style and content - something we normally avoid. However, I think this is better than simply forcing a set size in CSS as the results are better.
    Also, it has the advantage of working with all image formats whereas most scripts that resize images and create new files only support one file - typically jpg.
    My recommendation for storing images of the size you want is to resize them before you upload them to your site. That way you get the file size you want. If you apply this idea with this script you can resize the file to the max size you are going to support on your site and then use the scrip to resize for thumbnails.
    nathj

  13. #113
    Foo Bar
    SitePoint Community Guest
    Doesn't work. Resized dimensions mismatch to width and height parameters provided to function.

  14. #114
    enea
    SitePoint Community Guest
    works perfectly!

    thank you, that's magical :)

  15. #115
    Shahriat
    SitePoint Community Guest
    works g8!

  16. #116
    Mark
    SitePoint Community Guest
    if you are looking to have different max height and different max width try the function below:

    <?
    function imageResize($width, $height) {
    $maxWidth = 310;
    $maxHeight = 221;
    if($width > $maxWidth){
    $widthPercentage = ($maxWidth / $width);
    }else{
    $widthPercentage = 1;
    }
    if($height > $maxHeight){
    $heightPercentage = ($maxHeight / $height);
    }else{
    $heightPercentage = 1;
    }
    if ($widthPercentage < $heightPercentage) {
    $width = round($width * $widthPercentage);
    $height = round($height * $widthPercentage);
    } else {
    $width = round($width * $heightPercentage);
    $height = round($height * $heightPercentage);
    }

    return "width=\"$width\" height=\"$height\"";

    }
    ?>

    Also if your image is smaller than than both max height and max width then it leaves it as is

  17. #117
    PHPElder
    SitePoint Community Guest
    This is horrible. Resizing an image is as much about saving bandwidth as it is about page layout. Using an html-scaled large image for a user on dialup is going to pain them to the point of never returning and tripple your bandwidth charges. You should just batch resize them into several general size (small, med, large) at the very least r use GD to resize uploaded images.

  18. #118
    Jeremy
    SitePoint Community Guest
    This isn't resizing anything. 1/10

  19. #119
    SitePoint Member
    Join Date
    Dec 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For those of you who don't understand much about advanced PHP. I've made an easy to use script that you can install on you server. It uses a Graphical user interface (PHP + HTML) for the settings and handles pretty much all your needs in term of image croping/resizing/compressing.

    You can find it here PictoPHP.com . Let me know what you think.
    Cheers.

  20. #120
    SitePoint Enthusiast RichestGirl's Avatar
    Join Date
    Nov 2008
    Location
    US
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Thanks for sharing nice script.

    Actually I am looking for some different type of resize script.

    Ex. I do not want to resize height and width but I want to resize size in KB.

    Ex. if some image is greater then 200KB then I want to reduce that image by resizing resolution without changing height and width to make its size to near 200KB.

    Is this possible?
    Please help.

    Thanks

  21. #121
    SitePoint Member
    Join Date
    Dec 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it is technically impossible to resize an image to a specific weight (in kb) . The only way to do this would be to make a script that would shrink the image each time by say 10% and check the new weight of the image.

    Calculation involved in image compression algorithm can not be '2 ways'. (Can't determine the input variables having the output result)
    So your best bet would be to 'brute force it' and go with trial/errors.
    Hope you have plenty of CPU on you server : )

  22. #122
    Vlads
    SitePoint Community Guest
    Thanks for sharing this scrips.

  23. #123
    floodedcodeboy
    SitePoint Community Guest
    I don't think simply having the width & height resized is going to make the actual image smaller... so if you have a 1MB image and simply constrain the HTML tag using your returned height and width - it's still going to laod all 1MB of that image!

  24. #124
    SitePoint Member
    Join Date
    Apr 2009
    Location
    Toronto
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good article, but one thing - if you have high traffic website, resizing images on the fly will kill the server, so for low traffic this would work, but for high traffic you should resize on upload and save few copies. It is more important to have fast site, then site that is slow but weight less!

  25. #125
    James Eggers
    SitePoint Community Guest
    On this line:
    <img src="jameseggers.com/Admin.jpeg" <?php echo imageResize($mysock[0],
    $mysock[1], 150); ?>/>

    It is necessary to put echo before imageResize.


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
  •