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
https://forums.phpfreaks.com/topic/250087-php-gd/
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
https://forums.phpfreaks.com/topic/250087-php-gd/#findComment-1283416
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.