Jump to content

image cropping help


areuban

Recommended Posts

hi guys, im new here! first post ;) i need to crop images from a database or directory. ive downloaded scripts and use them on their own. when i try to call the function like this <img src="crop.php?x=10&y=20&w=30&h=40&src=templates/new/images/site_header.jpg">  nothing works! what am i doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/215126-image-cropping-help/
Share on other sites

<?php

$w=$_GET['w'];

$h=isset($_GET['h'])?$_GET['h']:$w;   

$x=isset($_GET['x'])?$_GET['x']:0;   

$y=isset($_GET['y'])?$_GET['y']:0; 

$filename=$_GET['src'];

header('Content-type: image/jpg');

header('Content-Disposition: attachment; filename='.$src);

$image = imagecreatefromjpeg($filename);

$crop = imagecreatetruecolor($w,$h);

imagecopy ( $crop, $image, 0, 0, $x, $y, $w, $h );

imagejpeg($crop);

?>

Link to comment
https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1118921
Share on other sites

UPDATE: ok this is the script i have now (SimpleImage.php) then i created this :<?php

  if( isset($_POST['submit']) ) {

      include('SimpleImage.php');

      $image = new SimpleImage();

      $image->load($_FILES['uploaded_image']['tmp_name']);

      $image->resizeToWidth(150);

      $image->output();

  } else {

?>

 

  <form action="upload.php" method="post" enctype="multipart/form-data">

      <input type="file" name="uploaded_image" />

      <input type="submit" name="submit" value="Upload" />

  </form>

 

How can i then output the resulting image as part of an html file? after it has resized and saved it? please help

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/215126-image-cropping-help/#findComment-1118978
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.