Jump to content

PHP & GD


hackalive

Recommended Posts

Hi guys,

I am after some GD/PHP code that selects out an area of a larger picture.

 

It must use x1, y1 to x1, y2 rather than x1, y1 and then a dimension, that is it must use coordinates.

 

It must then parse the selection to a php function, not sure how to do this, but one idea is for it to send the selection to a tmp folder then parse the new image file

 

Any help is very much appreciated.

Link to comment
Share on other sites

Im using this code

<?php

$w=$_GET['w'];

$h=isset($_GET['h'])?$_GET['h']:$w;    // h est facultatif, =w par d&#233;faut

$x=isset($_GET['x'])?$_GET['x']:0;    // x est facultatif, 0 par d&#233;faut

$y=isset($_GET['y'])?$_GET['y']:0;    // y est facultatif, 0 par d&#233;faut

$filename=$_GET['src'];

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

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

$image = imagecreatefromjpeg($filename);

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

imagefilter($image, IMG_FILTER_GRAYSCALE);

imagefilter($image, IMG_FILTER_CONTRAST, -100);

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

imagejpeg($crop);

?>

 

problem is, its doing like a "zoom in" I need it to keep the aspect ratio.

 

Any ideas how I can do this?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.