www.webdeveloper.com
Results 1 to 3 of 3

Thread: Image crop and resize..

  1. #1
    Join Date
    Sep 2008
    Posts
    61

    Image crop and resize..

    Hey!

    I've got a little problem.. I'm making a little custom "image-editor" in PHP and Javascript.. the Javascript is not the biggest worry..

    Well.. my problem is in this code :

    PHP Code:
    $add="original/picture.jpg"

    $im=imagecreatefromjpeg($add);

    $width1 = (imagesx($im) * $prop1);
    $height1 = (imagesy($im) * $prop1) * $prop1;

    $width2 = (imagesx($im) * $prop2) / $i;
    $height2 = (imagesy($im) * $prop2) / $i;

    $width3 = (imagesx($im) * $prop3);
    $height3 = (imagesy($im) * $prop3) / $i;

    $nimage=imagecreatetruecolor(900250);
    $fimage=imagecreatetruecolor(450279);
    $bwimageimagecreatetruecolor(249146);

    imagecopyresized($nimage,$im,0,0,$x1,$y1,900,250,$width1,$height1);
    imagecopyresized($fimage,$im,0,0,$x2,$y2,450,279,$width2,$height2);
    imagecopyresized($bwimage,$im,0,0,$x3,$y3,249,146,$width3,$height3); 
    The prop-variables comes from the javascript page.. it's how much the picture should be re-sized in percent (eg. 0.63). But I suck at Math this way.. so I've got no idea how to get the new width and stuff from that.. I've tried as you might see.. but It's not working correctly..

    The $x1, $y1, etc. variables also comes from the JS page.. Where the user can move and re-size a div, proportionally to (900, 250) etc. And that's where the pictures left and top should start out from.. and that works.. kinda..

    The $i variable is just some stupid variable I made for the JS page... it tells how big the picture's width is towards 900px, in percent.. ($i = 900 / picWidth)

    I would really appreciate any help I could get on this!

    Thanks!

    //Artheus

  2. #2
    Join Date
    Sep 2008
    Posts
    61
    hey again.. I hope I will get an answer very soon.. because I'm in a bit of a hurry with this project.. dead-line tomorrow.. and I can't really continue before I've solved this problem..
    Would be forever thankful to an answer!

    Cheers,
    Artheus

  3. #3
    Join Date
    Sep 2008
    Location
    Tel Aviv, Berlin, L.A.
    Posts
    165
    What EXACTLY do you need to know? How to calculate proportions (like height gets adjusted proportional to width)? Or is it a question on how to calculate percentages?

    Waiting to help...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles