Results 1 to 2 of 2

Thread: working with php images

  1. #1
    Join Date
    Feb 2009
    Posts
    156
    Thanks
    0
    Thanked 4 Times in 3 Posts

    Default working with php images

    hello ,
    i am working with php...

    i face a problem in image creations...
    i have different size pictures and i need to resize those pictures , (regardles its ratio)
    i.e. there is a picture size (360 x 640) and i need to resize it with (240 x 320)
    i just want to resize it and cut the rmaining portion of picture from the bottom side( which is not in ratio)
    i just want to display tht picture , not save picture...



    plz help , all suggestion would be appriciated... thanks in adv

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Determine the height and width; change them as you want. Then copy to a new image with the new dimensions.
    http://www.php.net/manual/en/functio...yresampled.php

    There is a lot of information available there. Cropping is maybe the most complicated part, but you can do this in the following way: first, determine new width then calculate the desired new height. Based on that, you can use the $src_x, $src_y, $src_w and $src_h to select the upper left corner and then how much of the image you want, such as "0,0,360,480": start at the far upper left corner then take a section that is 360 wide (full original width) and 480 tall--- that's the hard number to determine: it's in the same ratio as the new image. Algebra: 320/240 = X/360. => X = (360*320)/240 = 480.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •